Crash when F.Requery returns no records

  • Thread starter Brian via AccessMonster.com
  • Start date
B

Brian via AccessMonster.com

I am using the code below to synchronize two forms. The relationship is one to many. It works fine until I go to a record in the main form that doesn't have any records in the popup form. Check18 is a check box. When checked the popup is open.

Private Sub Form_Current()
If Check18 Then
Dim F As Form
Set F=Forms![popup]
F.RecordSource="Select * FROM popup Where [id]='" & Me![id] & "';"
F.Requery
End If
End Sub
 
J

John Vinson

I am using the code below to synchronize two forms. The relationship is one to many. It works fine until I go to a record in the main form that doesn't have any records in the popup form. Check18 is a check box. When checked the popup is open.

Private Sub Form_Current()
If Check18 Then
Dim F As Form
Set F=Forms![popup]
F.RecordSource="Select * FROM popup Where [id]='" & Me![id] & "';"
F.Requery
End If
End Sub

What sort of "crash"? What error message do you get?

In fact the Requery should not be necessary. Simply setting a Form's
Recordsource to a text string should do the initial query.

I'm wondering why you want to do this in this way - might not a
Subform (which does the same thing with no code), or closing and
reopening the popup form with a WhereCondition in the OpenForm call be
preferable?

John W. Vinson[MVP]
 

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