N
Nikki Norris via AccessMonster.com
I just took this code over and tried to make changes, but it's not working.
Scenario: I'm on a blank form with a company name drop down. I pick a
company name from the drop-down and the first record populates the form and
the label reflects the company name. I now decide to pick another company
name, but there are no records for this company.
How do I check that there are no records, blank out/Clear the fields from
the previous records, then do not change the label, but give the user a
popup "no records found"???
Here's my code:
Private Sub Combo170_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Companyid] = " & Str(Nz(Me![Combo170], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Dim SQL As String
SQL = "Select * from qryJOProfile Where Companyid=" & Me.Combo170.Value
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "NO RECORDS FOR THIS VENDOR."
'Cancel = True
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
Dim sFilter As String
sFilter = [CompanyName]
Me!Label90.Caption = sFilter
End If
End Sub
Thanks,,
Nikki
Scenario: I'm on a blank form with a company name drop down. I pick a
company name from the drop-down and the first record populates the form and
the label reflects the company name. I now decide to pick another company
name, but there are no records for this company.
How do I check that there are no records, blank out/Clear the fields from
the previous records, then do not change the label, but give the user a
popup "no records found"???
Here's my code:
Private Sub Combo170_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Companyid] = " & Str(Nz(Me![Combo170], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Dim SQL As String
SQL = "Select * from qryJOProfile Where Companyid=" & Me.Combo170.Value
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "NO RECORDS FOR THIS VENDOR."
'Cancel = True
DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
Else
Dim sFilter As String
sFilter = [CompanyName]
Me!Label90.Caption = sFilter
End If
End Sub
Thanks,,
Nikki