Error Messages On Forms

GarageFlower

Registered User.
Local time
Today, 12:10
Joined
May 20, 2004
Messages
108
I have a form with the text box "Project Name"

I have used a command button placed next to the project name box which if clicked opens up a finance details form for the project name box.

Problem is if that project does not have any finance details it still opens up the form but just comes up as totally blank.

Is there anyway i can get an error message to come up and say
"No matching data found for this project" when they click the command button to open up the finance form, but there is no finance data?

I have tried but unsuccessfully.

I entered this code

Private Sub Label75_Click()
On Error GoTo Err_Label75_Click
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Contract Filtered"

If Combo22 = "" Then
MsgBox "No Matching Data Found", vbExclamation

End If

stLinkCriteria = "[Project Number]=" & Me![ProjectName]
DoCmd.OpenForm stDocName, , , stLinkCriteria





Exit_Label75_Click:
Exit Sub

Err_Label75_Click:
MsgBox Err.Description
Resume Exit_Label75_Click

End Sub


But instead of not opening the blank form, it comes up with the error message and then opens the blank form.

Or if there is finance data for that project it comes up with the error box still and opens the form

Any ideas people?

Thank you please
 
A lazy way around it...

Use a macro to open the form on a Condition rule... (where this is true)

Then when it works convert the macro back to VB.

Hope this helps... even if it is poor practise, it will work.

Mike
 
Ok here is an attachment of what im doing

On the startup form select
"Armoured Vehicles"

And then click search

It will open up another form.

Then click contract at the top of the screen in this form and it will open up a new form with details of that contract.

Which is fine and good

But then go back to the startup form and chose E3d Simulator (the last in the list) click search and then try openiong the contract form at the top of the screen.


Opens a blank form as there is no related record.

How can i get it to come up with an error message instead of opening the blank form?
 

Attachments

Mike could you explain that a bit more please?

I still need an error message coming up to tell the user that there is no matching record found....
 
Private Sub Form_Open(Cancel As Integer)
If (RecordsetClone.RecordCount = 0) Then
DoCmd.Close
Beep
MsgBox "There are no invoices recorded for that period.", vbInformation, "No Invoices Recorded"
End If
 
Sorry mate

Have tried that and it just comes up with the debugger

not sure why
 
What's the debugger say?
 
well first of all im not even sure what form im supposed to put the code in on the on open event....

im guessing the target form

dont suppose someone could do this with the example form i attached.
 
dude thanks for your advice but i have the database structure up and running fine without any other problems than the one i am asking about.

This database has another 28 tables and about 36 forms.

Believe me i am happy with the structure...

Thank you though......
 

Users who are viewing this thread

Back
Top Bottom