Starting up a form at the right place????

pdbowling

Registered User.
Local time
Today, 13:35
Joined
Feb 14, 2003
Messages
179
Hi all. Can anyone help with this?

I am launching a form at database startup. No problems there. It starts the form and displays record one. I was wondering if there was a way to get it to jump to the empty record at the end of the table so they will be where they need to enter new data,(to minimize key strokes). Thanks so much.
PB
 
pdbowling said:
Hi all. Can anyone help with this?

I am launching a form at database startup. No problems there. It starts the form and displays record one. I was wondering if there was a way to get it to jump to the empty record at the end of the table so they will be where they need to enter new data,(to minimize key strokes). Thanks so much.
PB

If it's strictly for data entry, set the form's dataentry property to yes. Otherwise, in the OnOpen event, call a macro that moves to the last record or to a new, blank record (search Access help for MoveLast or "create new record").

--Monday Mac
 
OnOpen of the form

DoCmd.GoToRecord , , acNewRec

Col
:cool:
 
Thanks

Thank you so much, all.

I'm learning tons from you.

PB
 
Could anyone help me. i am try to do a similar thing, but when the user puts in their u/name and p/word, i want them only to see their own records and nobody elses.
I have code that allows them to jump to the start of their records (using 'staff name' as an identifier) but i would like their view restricted.
 
I fyou use the DoCmd.OpenForm "FormName" you can use the WHERE criteria to say WHERE [Staff Name] = YourStaffMember
 
Private Sub Form_Open(Cancel As Integer)
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Staff Name] = '" & [Forms]![Security2]![txtUserName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark



End Sub


this is what i've got so far. The 'Security2' is the form i use onOpen of DB, and the user eneters their name and p/w, which opens the form Mandays, which has this code onOpen. Though it's not what i'm after...
 
If you use what I said before then the form will open up with only those records that belong to the person.

Use it on your Security2 form whether on a command button or whatever.

Code:
DoCmd.OpenForm "Mandays", acNormal, , "[Staff Name] = '" & Me.txtUserName & "'", acFormReadOnly, acWindowNormal
 
this is what i've got, but i keep getting an error re: txtUserName


Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

DoCmd.OpenForm "Mandays"
Where [StaffName] = "'" & [Forms]![Security3]![txtUserName] & "'"
Exit_Form_Open:

Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open

End Sub
End Sub


It says 'Sub or Function not defined'.
I know that instead of - Where [StaffName] = "'" & [Forms]![Security3]![txtUserName] & "'"
i should have Where[StaffName] = "Alison", but this way, i would have to write code for each member of staff.

Am i being confusing. sorry if i am
 
Three things:

i) what form is this code on?

ii) You said the form was called Security2 but you are referencing a form called Security3

iii) the WHERE should not be there, but the condition should be part of the DoCm.OpenForm line
 
And a fourth point, you have two End Sub lines.
 
Sorry i am being confusing...

i) Code is on form 'Mandays', OnOpen. I have a form called Security, which the user puts in username and password. they click 'ok' and providing the names match, the form 'Mandays' opens, but only at the records of the 'username'.

ii) the second form is called Security. i have put the numbers after the word cos i'm trying variations of code and instead of deleting things i've tried, i create new forms.

I'm trying this, but it still won't work. help! i'm going nuts!

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open

DoCmd.OpenForm "Mandays", , [StaffName] = "'" & [Forms]![Security]![txtUserName] & "'"
Exit_Form_Open:

Err_Form_Open:
MsgBox Err.Description
Resume Exit_Form_Open


End Sub
 
This line goes on the OK command button on security.

DoCmd.OpenForm "Mandays", , [StaffName] = "'" & [Forms]![Security]![txtUserName] & "'"
 
Got it!
this works

DoCmd.OpenForm "Mandays", , , "[Staff Name]='name'"

thanks for your help.

anita
 

Users who are viewing this thread

Back
Top Bottom