open form help

S

sue gray

I have a command button on a form that I am trying to use to open a blank
form based upon clientid. When I test the form and use the command button it
brings up all the notes for all clients.

Private Sub cmdAddContactNote_Click()
' This code adds a new contact note based on client id.
On Error GoTo Err_cmdAddContactNote_Click

Dim strDocName As String

strDocName = "frmcontactnote"

' Open Contact Note form in data entry mode and store ClientID in
' the form's OpenArgs property.

DoCmd.OpenForm strDocName, , , , acAdd, , Me!clientid

If IsNull(Forms!frmcontactnote!clientid) Then
Forms!frmcontactnote!clientid = Me!clientid
Forms!frmcontactnote!ContactType.SetFocus

End If


Exit_cmdAddContactNote_Click:
Exit Sub

Err_cmdAddContactNote_Click:
MsgBox Err.Description
Resume Exit_cmdAddContactNote_Click

End Sub

I have tried to find the mistake, I put msgbox me!clientid after the docmd.
It shows I have the correct client.

Thanks for any help
 
D

Damon Heron

You didn't say what was on the frmcontactnote, but
in the Open event, you should have:
Dim ID As Integer
ID = Forms!Form4.OpenArgs 'this is the argument you passed to the form

DoCmd.GoToControl "yourclientID" 'your control name
DoCmd.FindRecord ID, , True, , True, , True

Damon
 

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

Top