query outcomes

  • Thread starter Thread starter sheena
  • Start date Start date
S

sheena

hi,

i have created a form with search options. it allows the user to search the
databases, each search option e.g. "Find Customer" the customer will click on
the button and a box will appear asking the user to enter the Customer
Account Number. if the number exsists the databases opens n shows the record
for that customer. if it doesnt exsist the database opens and shows a blank
record. it it possible for a message to appear sayin the record doesnt
exsists rather than opening a blank database.
if so how can this be done. I am a new user to Access so the simplest
method would be great.

Thank you
Sheena
 
First off I'm assuming that you mean tables and not databases. In a nutshell,
a database is a collection of tables.

When you do a search, what opens to show the records? Form, Query, Table, or
Report?

If a report, there's a On No Data event that handles what you want. For the
other objects, it will take some work.
 
Hi jerry,

Sorry i apologies yes i mean a table opens. My query is connected to a table
not a report. Are you able to explain how i can do this and i will try and
give it a go please.

Thank you
Sheena
 
You really can't do it with a query directly. You could put something like
this in the On Click of the button that you use for running the query.

Private Sub cmdRunQuery_Click()

If DCount("[NHA]", "qryNHA") < 1 Then
MsgBox "No Records"
Else
DoCmd.OpenQuery "qryNHA"
End If

End Sub

It won't work on Parameter queries.

In a report, there's a On No Data event that handles what you want.

For a form you need to write some code that would check for records. Check
out the BOF and EOF Properties in Help.
 
Hi jerry,

as you know i'm not to familar with Access infact this is my first time
using it.

this is the code thats already in VBA where do i need to add the code that
you have given me.

if you could make it personal to my query my query is called "Fraud search
by cheque value" and my form name is "Fraud_Step_4". would you also explain
to me what each bit does and how it function just for future reference.

Thank you
sheena


Private Sub srchfrd_Click()
On Error GoTo Err_srchfrd_Click

Dim stDocName As String

stDocName = "Fraud search by cheque value"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_srchfrd_Click:
Exit Sub

Err_srchfrd_Click:
MsgBox Err.Description
Resume Exit_srchfrd_Click

End Sub
 
Back
Top