Use Openargs while creating new record

  • Thread starter Kevin via AccessMonster.com
  • Start date
K

Kevin via AccessMonster.com

Hello,

I have a form "addPatient" used for the entry of new records that contains
fields for Medical Record number (PK), Last Name, and First Name. This form
opens when a "Create new record" command button is pressed on a search form
"editPatientInfo". When the user clicks a command button to close addPatient,
I would like "editPatientInfo" to be updated to the record that was just
added so that the rest of the fields associated with that patient can then be
edited. I've tried using OpenArgs, however, I have limited VBA experience and
have run into trouble. Here's my current code:
-----------------------------------
Private Sub Form_Open(Cancel As Integer)
'for the form "editPatientInfo"
If Function_fIsLoaded = True Then
Dim strNew As String
strNew = Forms!addPatient.OpenArgs
If Len(strNew) > 0 Then
DoCmd.GoToControl "Me.[Medical Record Number]"
DoCmd.FindRecord strNew, , True, , True, , True
Me.Detail.Visible = True
End If
Else
Me.Combo2.SetFocus
Me.sbfStudyEnrollment.Locked = True
Me.Detail.Visible = False
End If
End Sub
---------------------------------
The function fIsLoaded is as follows:
---------------------------------
Public Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, addPatient) <> 0 Then
If [Forms]!addPatient.CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
 

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