Hi all,
i need you help with a record search code of mine which was and works on an earlier version of my database but not on this latest version I have had to redevelop and re-assign tables etc because I had made 2 initial fundamental design errors of saving text data to tables instead of binary and I also I wasn't using bound forms to insert/update records which I got stick for on here when I asked if I would have problems deploying for multi-users over a network.
Anyhow...issue is my search code on new version works and shows my records in the frmOrgDetailsP when matching records are found. However in the new version if no records are found I just get a completely black screen whereas in my earlier working version if no records were found I would still get the frmOrgDetailsP load up but with no records showing which was ok because the form has buttons to return to main search page and start/try again. New version it like it's frozen out.
nothing has really changed from the two form versions...
any ideas of code I can add to determine is the search hactually contains records and if not display a message "No matching records found, try again" and not load the frmOrgDetailsP form.
Much appreciated
i need you help with a record search code of mine which was and works on an earlier version of my database but not on this latest version I have had to redevelop and re-assign tables etc because I had made 2 initial fundamental design errors of saving text data to tables instead of binary and I also I wasn't using bound forms to insert/update records which I got stick for on here when I asked if I would have problems deploying for multi-users over a network.
Anyhow...issue is my search code on new version works and shows my records in the frmOrgDetailsP when matching records are found. However in the new version if no records are found I just get a completely black screen whereas in my earlier working version if no records were found I would still get the frmOrgDetailsP load up but with no records showing which was ok because the form has buttons to return to main search page and start/try again. New version it like it's frozen out.
nothing has really changed from the two form versions...
any ideas of code I can add to determine is the search hactually contains records and if not display a message "No matching records found, try again" and not load the frmOrgDetailsP form.
Code:
Private Sub search_record()
Dim recfield As String
Me.cmbchooseDept = Nz(Me.cmbchooseDept, "")
If Me.cmbchooseDept = "" Then
MsgBox ("Please choose a Department first from the Top Left of the page!"), , "Blank field Error!"
Me.cmbchooseDept.SetFocus
Exit Sub
End If
Me.txtsearch = Nz(Me.txtsearch, "")
If Me.txtsearch = "" Then
MsgBox ("No search details have been entered!"), , "Blank field Error!"
Me.txtsearch.SetFocus
Exit Sub
End If
recfield = Me.txtsearch.Value
If Me.cmbchooseDept = "Plowing" Then
If Me.sfilter.Value = "Pref No." Then
'example DoCmd.OpenForm "Employees", , , "LastName = 'King'"
DoCmd.OpenForm "frmOrgDetailsP", , , "appNo = '" & recfield & "'"
ElseIf Me.sfilter.Value = "Application No." Then
DoCmd.OpenForm "frmOrgDetailsP", , , "appNo = '" & recfield & "'"
ElseIf Me.sfilter.Value = "Org. Name" Then
DoCmd.OpenForm "frmOrgDetailsP", , , "organisationName Like '*" & recfield & "*'"
Else
DoCmd.OpenForm "frmOrgDetailsP", , , "organisationName Like '*" & recfield & "*'"
End If
Endif
End sub
Much appreciated