Code Before Opening Form To Check User's Right

Oct 23, 2005

Hello Gentlemen,

I am planning to give different rights (AllowEdit, ViewOnly…) to the user on accessing forms and reports in a db on a single pc instead of dealing with server as my client have only one pc.

As a present requirement, db would be in one pc only and would be used by 3-4 users. I need each of users to limit their access to some of the forms and reports in the same pc. To get it, what I did is as follows:

Example:

One of my tables called tblEmployees (Back End Table) linked in FE containing following fields:

1.Unumber- Autonumber
2.UNames - Text
3.Pwd- Password
4.F1- Yes/No
5.F2- Yes/No
6.F3- Yes/No

F1, F2….stands for form1, form2…

There is a login menu form. Something like 2 text boxes on the form and opening at the startup. User selects his name from a combo and types his password. If the user is available in the tblEmployees, Access opens main form and store UNumber and UName with time stamp in a local table called “T_CurrUser. If user not available in tblEmployees, it should close or give some msg.

Now, when the Main form opens (after login with correct user and pwd) and user wants to click different command buttons to open the form, I need to write code to check whether the current user have right to open the selected form (check marked to allow opening this form in the table tblEmployees) BEFORE opening it.

If check mark is set to false on F1 in the table tblEmployees, it means he can’t open form1, and a msg should pop up “Not allowed to view”..Something likes that.

1. I don’t know the code I created with simple if then, where to write ? I mean on which event of form ? On open / On Activate or where. Bcz the code should run before form opens and should check the table whether the user have check mark value true or false.

I tried to write the following code but some time it works some time doesn’t. What is wrong with code lines?

On Click of Command Button that opens Form1

Dim USR = DlookUp(“lngEmpId”,”T_CurrUser”) ‘ Local Table emp.

‘To check if Form1 check mark is set to true
If DlookUp(“F1”,”tblEmployees”,”lngEmpId=USR)=True Then
Docmd.OpenForm “Form1”
Else
End If

When another user logs on the same pc (off course, after login out of first user) the local table T_CurrUser record will be replaced with new user. Note that local table T_CurrUser contains always one record. Hopefully I described correctly.

Any idea will be respected.

With kind regards

Ashfaque

View Replies


ADVERTISEMENT

Check Record Count Before Opening Form

Dec 22, 2004

How do I check, before opening the form, whether any records exist in the table bound to the form?

Thanks

View 3 Replies View Related

Check Box VBA Code In A Form

Feb 17, 2015

I am trying to create form. I have a check box in my form with the name ChkDone.

I am going to write code for this check box and link it with some fields in my form.

The plan is if the check box is true or yes those fields will be available to insert data and if not they will be disabled.

View 3 Replies View Related

Opening Up A Report From A Form - However, It Requires User Input!

Jul 10, 2006

Hi,

I have a report that requires the user's input for a field called UserID.

I also have a form in which I want to have a button that can be used to print off this report (which would involve automatically entering the UserID into it). How do I do this?

Here is the code for the form button that I am using at the moment, but when you click it, Access still needs the UserID (duh!). So, how can I automate the input?

Code:Private Sub Command25_Click()On Error GoTo Err_Command25_Click Dim stDocName As String stDocName = "Menu" DoCmd.OpenReport stDocName, acNormalExit_Command25_Click: Exit SubErr_Command25_Click: MsgBox Err.Description Resume Exit_Command25_Click End Sub

View 5 Replies View Related

Forms :: User Login Form On Opening Of Database

Feb 17, 2015

I need to know the procedure or event code for user login form at opening.

I am working on database which is almost done and i defined tables for users with passwords.

I need to know how i can assign Login Form to be appear on opening of database no other person than listed users should be able to enter or open database without password, to enforce this i made a login form.

View 5 Replies View Related

Identifying Form - Check Username And Password Of A User

Jan 15, 2015

How to make a form that must Check the username and password of a user, in case if they are true then let the user to visit other forms and Tables...

View 1 Replies View Related

Modules & VBA :: Code That Warns User Before Closing Form

Sep 17, 2013

I am very new to Microsoft Access...

Private Sub Command79_Click()
On Error GoTo Err_Command79_Click
'the following code is supposed to warn the user if there is no STOP filling time for each START filling time before the main form is closed

If [Text344] > #12:00:01 AM# Then
If [Text365] >= [Text344] Then

[Code] ....

View 8 Replies View Related

Check For Existing Record Before Opening

Sep 20, 2006

Hi.

I have 2 forms, with a "PNID" field as the link between the 2.
In the 2nd form, the PNID field allows no duplicates. I have a button on the first form to open the 2nd form to add a record.

I need some code to put on the button on the 1st form to check whether a PNID record exists on the 2nd form before opening it.......does this make sense?
What is happening is that I click on the button, try and add a record, then it tells me one exists and I cannot add a duplicate...

I have looked at the threads, and have tried using DCount? Is this correct?

Thanks

Frank.

View 7 Replies View Related

Code For Opening A Report

Sep 2, 2005

Hey there, if anyone could help me with the code for opening a report please. I have a main page with buttons, and need a button for opening reports.. thx

View 1 Replies View Related

Code For Check Box

Feb 22, 2006

friends,

I have a form based on a table (master) with a cbo which returns yes or no according to what users select.

I then have another form which get's its data from a query based on the above table (master). This time, the value I have selected in the previous form using the cbo, should be displayed using a check box.

This is how I would like it to work:

If Me.cbo = yes (meaning that the value selected is yes), then

check box should show be checked.

If Me.cbo indicated NO, then, the check box should not be checked.

Is there a way I can do this via code?

Thanks.

View 3 Replies View Related

Stop User From Opening FE MDE File Twice

Oct 18, 2007

Is there a way to stop users from opening the front end file twice (stop from having two sessions of the same FE at the same time)?

I've been searching the forum and found this
http://www.access-programmers.co.uk/forums/archive/index.php/t-67724.html
but since im not using an .exe updater is not my case t.t

View 5 Replies View Related

DAP-Can Someone Check This HTML Code For Me?

Apr 27, 2005

I'm trying to get a field in my Data Access Page to display the last time a field was updated, I figured I would have to do this in HTML, after a lot of dead ends elsewhere. Here is the code:

<SCRIPT language=vbscript event=BeforeUpdate(dscEventInfo) for=MSODSC>
<!--
Dim DateModified
DateModified = Date 'Current System Date
dscEventInfo.DataPage.Recordset.Fields("DateModified") = Date

-->
</SCRIPT>

Any clues where I would enter this in the HTML source?

View 1 Replies View Related

General :: Opening Access Database In Code As Read Only

Jul 30, 2013

I am trying to open up an Access database as read-only from another running Access database. The code I have to open the database currently reads:

"""C:Program FilesMicrosoft OfficeOFFICE11MSACCESS.EXE"" ""f:commonpattyTraining Database.mdb", 1)

How do I change to read only?

View 3 Replies View Related

How Would I Write This Code For Check Boxes

Mar 15, 2006

Here is my problem. I have several fields located on a form. The user has a problem finding the curser on what field its on. I did ok with the text fields, but I need to come up with something for the check boxes. Any Ideas

The code below works good for text fields. But I need to do the same for Check Boxes or the Check Box Label that is associated with the check Box.

Private Sub Ctl4bCode_Enter()
Me.Ctl4bCode.BackColor = RGB(255, 0, 0)

End Sub

Private Sub Ctl4bCode_Exit(Cancel As Integer)
Me.Ctl4bCode.BackColor = RGB(255, 255, 255)

End Sub


thanks

View 1 Replies View Related

Can You Check My Code? Cookie Info Into A Db, Thanks!

Aug 25, 2005

Hey guys nice and easy one im trying to put some info from a cookie into an access database this is the code i have:

Code:<%dim uiduid=Request.Cookies("tmg_login")("MemberID")sql="INSERT INTO genSiteNews (NewsTitle,News,NewsBy)"sql=sql & " VALUES "sql=sql & "('" & Request.Form("NewsTitle") & "',"sql=sql & "'" & Request.Form("News") & "',"sql=sql & "'" & uid & "')"on error resume nextoconn.Execute sql,recaffectedif err<>0 then Response.Write("Error!")else Response.Write("News Entered Ok!")end ifrs.closeoconn.close%>

comes up with error any ideas?

View 1 Replies View Related

Forms :: Closing Opening Form With Timer Then Opening Main Menu

Apr 7, 2014

I have a Form opening from Access Options. I would like to close this Form using the Timer. The following is the code I have used but it is not working.

Private Sub Cover_Page_Form_Load()
OpenTimer = Timer
End Sub
Private Sub Cover_Page_Form_Timer()
If (Timer - OpenTime) = 5 Then DoCmd.Close acForm, "Cover_Page_Form", acSaveYes
End Sub

Next question. If I can get this to work can I then use a DoCmd to open new Form within the code above or do I need a new process.

View 5 Replies View Related

General :: Taking User Input While Opening Database

Dec 7, 2012

In my database there are fields of type Date/Time, their default value is set to now(). But the problem is that those fields are automatically filled up by English system date. I want my own country's date format, without changing my system date format. So I decided, whenever database is opened it should ask for a date, so the user will give today's date and that date will be used automatically on those fields.

View 6 Replies View Related

Modules & VBA :: Check Datatype And Field Size In Code

Feb 6, 2015

I have created code to import and excel file and create a table from that info. Now I need to confirm that the import has the correct Datatype of Number and Fieldsize of Double for one of the columns.

View 2 Replies View Related

General :: How To Use Code In Button To Check Relationship Integrity

Aug 2, 2012

Suppose I have two tables:

"State"
"City"

Related to the relationship "one-to-many."

They also have enabled:

Enforce referential Integrity and Cascade Update Related Fields

Thus, it is possible to change the name of the state or city, but can not be deleted until the state is associated with some of the city.

I also made a form for the "state" in which is the list that contains a list of all states. The name of the list is "lstState". So that I can delete the "State" I make a button in form and I use the following code:

Code:
Private Sub DeleteState_Click ()
If IsNull (Me.lstState) Then
MsgBox "Select the state you want to delete", vbCritical
else
DoCmd.SetWarnings False

[Code] ....

Everything works fine when the state is not assigned to any one city. But the problem arises when trying to delete a state which is assigned to the city, that is when I select this state and click on the delete button then the state is not deleted - this is ok, but without any message told why the state is not deleted and that's the problem.

My question is how to make the code that the user receives a message that such State can not be deleted because there are cities that are associated with it.

View 1 Replies View Related

Modules & VBA :: Check User Level Then Continue

Aug 2, 2014

I am trying to check for certain user levels then if criteria is met it will ask to continue then clear a table..

Code:

Private Sub Command9_Click()
If strSecLvl = dev Or admin Or sprvsr Then
If MsgBox("Do you wish to clear the logs?", vbYesNo, "Clear Logs") = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete * from tblLogs"

[Code] ....

View 2 Replies View Related

Check Box Allowing User To Choose Records To Update

Mar 8, 2005

I need to have a query-based form open and allow users to check off (or otherwise indicate) which records they want to update.

I tried having a check box on a continuous form, but when you check one, you check them all. I did a search on this, and saw that if you make the check-box bound, then that will work. But I don't know what to bind it to. I don't want to add another field to an already large and complex table, and I don't know where to put it if not in main table.

View 5 Replies View Related

Forms :: User Click Code

Feb 17, 2014

Code:
Private Sub Check237_Click()
If Me.Check237.Value = "yes" Then
Me.Text239.Visible = True
Else
Me.Text239.Visible = fasle
End If
End Sub

I am using the code above and what the desired action is when the Check237 is checked then the Text239 is visible for the user to put in a comment. However, as of now when the check237 is checked the textbox dissapears.

View 3 Replies View Related

VBA Code To Require User To Enter A Value

Mar 14, 2012

I am trying to edit the following code to be able to require the user to enter a Loan number and keep prompting the user to enter a value as long as the field is blank. Once the field is filled in, then the code should go on to check if the sql condition is met and make the necessary change if met, then finally, I have a save command code that will require the user to save the record. Right now I am getting errors when I added the code to require the user to enter a field. I am new to loop and if statements in vba so I am not exactly sure how to structure it.

Code:
Private Sub Save_Record_Click()
Dim SQL As String
Do
If IsNull(Me![Loan Number]) Then MsgBox "Please Enter Loan Number. This is a required field."

[Code] ....

View 1 Replies View Related

Forms :: Make Image Appear In Form When There Is Check In Check Box From Table?

Jun 26, 2014

how can i make a image appear in my form when there is a check in the check box from the table?

View 14 Replies View Related

User Level Security Halts With Code

Jul 19, 2005

I have created a multi-user database and stepped through the security wizard to create accounts etc. The database also has VB code in it that calculates values for a text box based on values in the form.
The PROBLEM is that when I open the database which Auto Executes the form (with VB) to open, it halts with RunTime error 2147467259 which reads "You do not have necessary permissions to use the .mdb object".... then when I "Debug" this error it takes me to the VB code???? :confused:

The code works fine without security....

Thanks for any help

MK

View 1 Replies View Related

Limit User's Security Permission With Code

Sep 15, 2005

My db is secured using Access security but now find myself needing to code a little security work around if possible.

I have a form that has a subform. On the subform is a field named "Comments". The subform security only lets a particular group write to the fields it contains (including "Comments"). I have a new user that I need to allow to write to "Comments" but not to any of the other fields on the subform. I could make another subform with "Comments" only field and redo my security so that the original group can write to both subforms and new user can only write to "Comments" subform but I think it might be easier to code in that the new user is only allowed to write to field "Comments" in the existing subform. Every user logs into the db so I can get the user ID.

Is it possible to do this?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved