I am buffled. My problem is like so:
I have two forms. Form1 is a "dialog box" where a use specifies a date. OnClick opens Form2 with a criteria like this
DoCmd.OpenForm stDocName, , , stLinkCriteria
Form2 has a subform. Form2 has the following event Form_load(). The first run works fine. Form2 and its subform are populated. The second run does not populate the subform, only fields in the main form. If you make a change in the VBA code, even just putting a comment, it works again for one run and stop working for subsequent runs??? Please help.
I have two forms. Form1 is a "dialog box" where a use specifies a date. OnClick opens Form2 with a criteria like this
DoCmd.OpenForm stDocName, , , stLinkCriteria
Form2 has a subform. Form2 has the following event Form_load(). The first run works fine. Form2 and its subform are populated. The second run does not populate the subform, only fields in the main form. If you make a change in the VBA code, even just putting a comment, it works again for one run and stop working for subsequent runs??? Please help.
Code:
Private Sub Form_Load()
Dim db As Database
Dim rs As Recordset
SQL = "select * from purchase where [PURCHASEdate]=" & "#" & Forms![add - purchase dialog]![Date] & "#"
Set db = CurrentDb
Set rs = db.OpenRecordset(SQL)
'MsgBox SQL
If rs.RecordCount > 0 Then
rs.MoveLast
rs.MoveFirst
Me.PURCHASEroe = rs.Fields("PURCHASEroe")
'MsgBox rs.Fields("PURCHASEroe")
End If
rs.Close
End Sub