Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigating through numerous forms using VBA Access 2000 1

Status
Not open for further replies.

eussias

Programmer
Sep 25, 2001
97
AU
Can anyone help me??
I'm developing a VBA Access 2000 application and require some code that, when a new form is opened, it will immediately open the new active form at the corresponding record from the previous form. There is a common field (PATIENTNUM) across all forms.
Any help would be greatly appreciated.

 
Hi!

I'm not sure I followed everything, but you can open another form to a related record by using this code in the Form_Current event procedure:

DoCmd.OpenForm "YourFormName", , , "PatientNum = " & Me!PatientNum

This assumes PatientNum is numeric, if it is text use:

DoCmd.OpenForm "YourFormName", , , "PatientNum = '" & Me!PatientNum & "'"

hth
Jeff Bridgham
 
Hi, use this function

Public Function IsFormOpen(FormName As String) As Boolean
Dim frm As Form
For Each frm In Forms
If frm.Name = FormName Then
IsFormOpen = True
End If
Next frm
End Function

If the function return True then open the other form Best Regards

---
JoaoTL
NOSPAM_mail@jtl.co.pt
 
Jebry,

I tried your suggestion, but am now coming up with a error saying that the expression I entered is the wrong data type for one of the arguments. The PatientNum field is numeric, and I cannot work out why it is coming up with this error. Are you able to help me at all.

eussias
 
Hi!

Post the code you used and I will look at it and let you know if I see something amiss.

Jeff Bridgham
 
Jeff,

Here is the code...

DoCmd.OpenForm Form_Cognitive, , , "Client_Number = " & Me!Client_Number

Thanks
 
Hi!

The name of your form needs to be in quotes because Access is expecting a string there.

hth
Jeff Bridgham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top