Opening a form at a specific record

potatohead

Registered User.
Local time
Today, 17:47
Joined
Dec 23, 2005
Messages
10
Hi all

Im currently designing one of my first databases!

I've initiated a log on procedure, with a password.

A user enters their ID and password. Once the correct password is entered, the next form is then loaded up, to which they make some choices.

My problem is that I have lots of users, and I would like them to only access the page that is relevant to themse, and NOT be able to see anyone elses.

I gather there is a little bit of tweaking to go on the
docmd.openform...

line, and somehow incorporate the userID, but not entirely too sure what it is.

Apologies if this seems really easy!

All help appreciated - many thanks!
 
The following code will open a form called F01PersonDetails and locate it on the record with the unique ID - "ID"

The wizard for putting the command buttons will write similar code automatically for you. Will require tweaking if you need a different form depending on the user requesting the form.


Private Sub OpenInvdividualRecord_Click()
On Error GoTo Err_OpenInvdividualRecord_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "F01PersonDetails"

stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_OpenInvdividualRecord_Click:
Exit Sub

Err_OpenInvdividualRecord_Click:
MsgBox Err.Description
MsgBox "open individual error trapping"
Resume Exit_OpenInvdividualRecord_Click
 
Thanks for that very quick reply!!!

Just one question, however. If the 'ID' is entered in a previous form (ie the log on form, in text56) how do I incorporate this into opening another form at that record?

Ie, the log on screen requires you to put in your username and password. I would like the code to remember the username and open the other form at that record.

I tried the following code:

Docmd.openform "choice",,,"[ID] = Username"

Where, username had previously been identified earlier on in the code. However, it doesn't like using a variable as the filter, and the form opens with no record showing.

If, however, the 'Username' is replaced with an actual ID, then the form WILL open at that record.

I suppose my question is, is there anyway of adding a variable as a filter?

Hopefully this isn't too hard of a question to answer (!!) - I'm still only quite new to all of this, so apologies!

Cheers
 

Users who are viewing this thread

Back
Top Bottom