Called Form

  • Thread starter Thread starter Gary
  • Start date Start date
G

Gary

I have a simple database used here at work that performs
the following activate event:
Private Sub Form_Activate()
DoCmd.RunCommand acCmdDocRestore
End Sub

This form is called from a previous form that executes an
SQL query to retrieve records. If there is 1 record that
meets the query criteria, the form is called using the
following:
If rst.RecordCount = 1 Then
Dim stLinkCriteria As String
stLinkCriteria = "[ID]=" & rst![ID]
DoCmd.OpenForm "frmMaster", , , stLinkCriteria
Else
DoCmd.OpenForm "frmSelect", , , stLinkCriteria
End If

I am calling the Form frmMaster. The problem is no
records are ever loaded into frmMaster unless I return to
the calling form and re-execute the query *without*
closing out the frmMaster Form. Then, my record shows
up. I am out of ideas.
 
Graham,

I did some searching after I posted this question, and it
looked like I needed to set my form to "No" for Data
Entry. I will implement your solution as well. Thank you
for your assistance.

-----Original Message-----
Gary,

Before the "If rst.RecordCount = 1 Then" line, add the following code:
rst.MoveLast
rst.MoveFirst

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd- 0764559036.html


I have a simple database used here at work that performs
the following activate event:
Private Sub Form_Activate()
DoCmd.RunCommand acCmdDocRestore
End Sub

This form is called from a previous form that executes an
SQL query to retrieve records. If there is 1 record that
meets the query criteria, the form is called using the
following:
If rst.RecordCount = 1 Then
Dim stLinkCriteria As String
stLinkCriteria = "[ID]=" & rst![ID]
DoCmd.OpenForm "frmMaster", , , stLinkCriteria
Else
DoCmd.OpenForm "frmSelect", , , stLinkCriteria
End If

I am calling the Form frmMaster. The problem is no
records are ever loaded into frmMaster unless I return to
the calling form and re-execute the query *without*
closing out the frmMaster Form. Then, my record shows
up. I am out of ideas.


.
 
Back
Top