Opening form goes straight to new entry. (1 Viewer)

maneyact

Registered User.
Local time
Today, 04:07
Joined
May 31, 2008
Messages
13
Hi All,

I need some help if anyone has a moment! I have a form that when opened I want to view all past entries. I have a button on the form to allow me to add a new entry.

The problem is that when I open the form it automatically goes to a new entry and I don't know why. This is the coding I am using on the button to open the new form.

------------------------------
Private Sub Invoice_Click()
On Error GoTo Err_Invoice_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim GymnastID As Long

stDocName = "frmInvoice"
GymnastID = Me!GymnastID

stLinkCriteria = "[GymnastID]=" & Me![GymnastID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms(stDocName)![GymnastID] = GymnastID
Exit_Invoice_Click:
Exit Sub
Err_Invoice_Click:
MsgBox Err.Description
Resume Exit_Invoice_Click

End Sub
------------------------------

Cheers - Scott.
 

suepowell

Registered User.
Local time
Today, 12:07
Joined
Mar 25, 2003
Messages
282
HI

Try this line to open the form

DoCmd.Openform stDocName, , ,stLinkCriteria , acFormedit

it should force the form to open in edit mode to show all records rather than add mode to add new records only.

Sue
 

maneyact

Registered User.
Local time
Today, 04:07
Joined
May 31, 2008
Messages
13
Hi Sue,

Thanks for your suggestion. Just tried it but no joy. Hmmm, i'm at a loss.
 

suepowell

Registered User.
Local time
Today, 12:07
Joined
Mar 25, 2003
Messages
282
HI ,

Is there something in the on open or on load event of the form you are opening to take you straight to a new record. If not I'm at a loss too.

Aaha, just had a thought, you are opening the from using a criteria of gymnastid = me.gymnastid. therefore the invoice form will only show the records for that gymnast. If there are no records for that gymnast the form will open to input a new record.

If there should be records for that gymnast then check the criteria is exactly as it should be, including spelling.

If you want to see records for all the gymnasts then remove the criteria from the form opening line.

Sue
 

maneyact

Registered User.
Local time
Today, 04:07
Joined
May 31, 2008
Messages
13
Sue - Thank you!

I just opened a record and added an entry. The first time it opens with nothing in there it tries to add a new entry straight away. Once there is an entry in there, it goes to the last record entry which is exactly what I want.

Thanks again.
 

Users who are viewing this thread

Top Bottom