Blank form again

bodvoc

Red Sea Pedestrian
Local time
Today, 20:38
Joined
May 4, 2003
Messages
54
Help!!!

I have a form looking up patient details based on a query, a find patient button opens a pop up with boxes asking for surname and first name to be added and which the query uses to refresh the main form. and a find button that refreshes the main form...

But on click, if no one is found of that name the main form goes completely blank and the message box fails to show?? I have check the other post for this and nothing I do fixes it??? heres the code

Private Sub Run_Query_Click()
On Error GoTo Err_Run_Query_Click


Forms![Service User].Requery

If (RecordsetClone.RecordCount = 0) Then
Beep
MsgBox "Sorry, No one of that name found", vbOKOnly


End If

Exit_Run_Query_Click:
Exit Sub


Err_Run_Query_Click:

Resume Exit_Run_Query_Click

End Sub

Wot am I doing wrong???

Cheers

Bodvoc:confused:
 
Has your forms AllowAdditions set to True and is the underlying recordset updateable?
 
Hi Fizzio

Allowadditions is set to false cos this a veiw only screen, and pass on recordset?? it was working find to a few days ago... and nothing has changed re did the form and it still shows blank if no records are found....

Cheers bodvoc

Update.... Added the bit of code below that if on No Records Found it searches/requerys for a known record and also in error statement :D


If (Forms![Service User]![Surname] = "") Then
Beep
MsgBox "Sorry, No one of that name found", vbOKOnly
Me![Text0] = "j"
Me![Text2] = "zirf"
Forms![Service User].Requery

End If


Exit_Run_Query_Click:
Exit Sub


Err_Run_Query_Click:
Me![Text0] = "j"
Me![Text2] = "zirf"
Forms![Service User].Requery

Resume Exit_Run_Query_Click

End Sub

Is there a better way of doing this??

Cheers Bodvoc
 
Last edited:
With the AllowAdditions set to false, if the recordset is empty, the form has nothing to display, including blank controls for a new form, and therefore the recordset is not even created - hence the lack of an error message.

You could circumvent this in a couple of ways

1. Use a DCount
2. AllowAdditions (but trap for a new record)
3. Use a different search method eg FindFirst / Seek.

Example 1
Code:
Dim intResponse as integer
if DCount("[IDField]", "TableorQuerytoCountRecords", "[Forename] = '" & Forms![Service User]![Forename] _ 
& "' AND [Surname] = '" & Forms![Service User]![Surname] & "'") <1  Then
intResponse = MsgBox ("No Records Found, Do you want to try a new search?", vbYesNo, "No match")
select case intresponse

case VbYes
docmd.openform "Service User"

Case VbNo
docmd. close 'Close the Form
end select
end if
 
WOW Thanks

Cheers Fizzio

That looks a much better way of doing it, I will try it Tuesday when back to work..

Thanks ever so again

Bodvoc
 

Users who are viewing this thread

Back
Top Bottom