A
Amy E. Baggott
I have a form that has a combo box lookup. When the combo box is updated, it
clones the recordset, finds the company in the lookup box, and resets the
bookmark to the bookmark of that company, which fills in all the other fields
in the form with the company's information. However, some of the companies
in my database are marked "Inactive" and should not have orders created for
them (the purpose of this form). When an "Inactive" company is selected, a
dialog box opens giving the user the option of reactivating the company or
not. If they choose not to reactivate the company, they get a dialog telling
them that they cannot create an order for this company and to choose another.
Then I clear the combo box, but I cannot get the remaining fields to clear.
Any ideas on how I can fix this? The code for the combo box is:
Dim objRs As Object
Set objRs = Me.Recordset.Clone
objRs.FindFirst "[exh_masid] = '" & Me![CompanyLookup] & "'"
If Not objRs.EOF Then
Me.Bookmark = objRs.Bookmark
End If
'Check to see if the company is inactive.
If Me.Inactive = True Then
Dim vbResponse2 As Long
vbResponse2 = MsgBox( _
"This company has been marked as 'Inactive'." & vbCrLf & " You
should only reactivate it if you are certain you have the right company." &
vbCrLf & "" & vbCrLf & "Do you wish to reactivate this company?", _
vbYesNo + vbExclamation + vbDefaultButton1, _
"Inactive Record")
If vbResponse2 = vbYes Then 'User wants to reactivate the company
Me.Inactive = False 'Reactivate the company
Dim rsExclude As DAO.Recordset
Set rsExclude = CurrentDb.OpenRecordset("SELECT * FROM tblExclude
WHERE MasID ='" & Me.exh_masid & "'")
rsExclude.Edit 'Clear previously set exclusions.
rsExclude![NoMail] = False
rsExclude![NoFax] = False
rsExclude![NoEmail] = False
rsExclude.Update
rsExclude.Close
Else
Call MsgBox( _
"You may not create a new order for an inactive company." & vbCrLf
& "" & vbCrLf & "Please choose another company.", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"Inactive Record")
Me.CompanyLookup = ""
Exit Sub
End If
End If
Me![AddOrderBtn].Visible = True
Please help. TNX
clones the recordset, finds the company in the lookup box, and resets the
bookmark to the bookmark of that company, which fills in all the other fields
in the form with the company's information. However, some of the companies
in my database are marked "Inactive" and should not have orders created for
them (the purpose of this form). When an "Inactive" company is selected, a
dialog box opens giving the user the option of reactivating the company or
not. If they choose not to reactivate the company, they get a dialog telling
them that they cannot create an order for this company and to choose another.
Then I clear the combo box, but I cannot get the remaining fields to clear.
Any ideas on how I can fix this? The code for the combo box is:
Dim objRs As Object
Set objRs = Me.Recordset.Clone
objRs.FindFirst "[exh_masid] = '" & Me![CompanyLookup] & "'"
If Not objRs.EOF Then
Me.Bookmark = objRs.Bookmark
End If
'Check to see if the company is inactive.
If Me.Inactive = True Then
Dim vbResponse2 As Long
vbResponse2 = MsgBox( _
"This company has been marked as 'Inactive'." & vbCrLf & " You
should only reactivate it if you are certain you have the right company." &
vbCrLf & "" & vbCrLf & "Do you wish to reactivate this company?", _
vbYesNo + vbExclamation + vbDefaultButton1, _
"Inactive Record")
If vbResponse2 = vbYes Then 'User wants to reactivate the company
Me.Inactive = False 'Reactivate the company
Dim rsExclude As DAO.Recordset
Set rsExclude = CurrentDb.OpenRecordset("SELECT * FROM tblExclude
WHERE MasID ='" & Me.exh_masid & "'")
rsExclude.Edit 'Clear previously set exclusions.
rsExclude![NoMail] = False
rsExclude![NoFax] = False
rsExclude![NoEmail] = False
rsExclude.Update
rsExclude.Close
Else
Call MsgBox( _
"You may not create a new order for an inactive company." & vbCrLf
& "" & vbCrLf & "Please choose another company.", _
vbOKOnly + vbExclamation + vbDefaultButton1, _
"Inactive Record")
Me.CompanyLookup = ""
Exit Sub
End If
End If
Me![AddOrderBtn].Visible = True
Please help. TNX