In opening a form designed to serve two purposes, the RecordSource is changed at open time. When a temporary query is used, the intent is to clear all the records that would have lingered from previous sessions of the app. The SQL DELETE statement fails with a FROM clause error 3131. In the current situation, the query (table) is already empty.
Code:
Private Sub Form_Open(Cancel As Integer)
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
' If we're opening for a new subscriber, we need to bind the controls to
' a temporary empty duplicate query. The rs.AddNew code will put the new
' subscriber where he/she belongs depending on what actions they choose.
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
If Len(Me.OpenArgs & "") = 0 Then
bolNewSubscriber = True
Me.lblHeader.Caption = "Profile for ""New Subscriber"""
DoCmd.RunSQL "DELETE * FROM QTempSubscribers)"
Me.RecordSource = "QTempSubScribers"
Else
Me.lblHeader.Caption = "Edit Subscriber Profile" 'EDit an existing subscriber
Me.RecordSource = "QSubscribers" 'Our current collection
Me.Filter = "SubID = " & Me.OpenArgs 'The subscriber being serviced
Me.Requery 'Okay, just the one record of interest
bolNewSubscriber = False 'Boolean flag for the SAVE code
End If
'*=*=*=*=(Initialize required fields)=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
strCompl = Split(strReqCtls, ";")
TestCompl
End Sub