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:
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.
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
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.
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
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?
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
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 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
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?
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)
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.
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.
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.
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.
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"
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.
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.
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."
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:
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.