GoToRecord

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

Hi all,

I want to goto a specific record. I am assuming I'd use the DoCmd.GoToRecord.
However I don't see how I would do this.. I have the below code that is on
the Form Open function.

Private Sub Form_Open(Cancel As Integer)
Dim SID As String

SID = Me.OpenArgs

If DCount("QuoteID", "tblCreditCardOrders", SID) >= 1 Then

'DoCmd.GoToRecord......?????
Else
DoCmd.GoToRecord , , acNewRec

Me.QuoteID = Me.OpenArgs

End If

End Sub
 
J

Jeanette Cunningham

Hi mattc66,
I find it is easier to put this type of code on the calling form (the form
that is opening the form where you want to filter or go to new).

Private Sub MyBtn_Click()
If DCount("QuoteID", "tblCreditCardOrders", SID) >= 1 Then
DoCmd.OpenForm "NameOfForm", , "[SID] = " & Me.SID
Else
DoCmd.OpenForm "NameOfForm", OpenArgs:="new"
End

On the form that is being opened you can put

Private Sub Form_Open(Cancel As Integer)
If Len(Me.OpenArgs & vbNullString) >0 Then
If Me.OpenArgs = "new" Then
DoCmd.GoToRecord, , acNewRecord
End If
End If

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top