Screen blanks when record does not exist

G

Guest

Hi,

I would like to move the 'APPLY FILTER' button from the toolbar to my
'search form' and add coding to this command to prompt the user when a record
does not exist in my table.

My 'search form' is opened using a command button on my 'main form'. See my
coding below.

Private Sub Command10_Click()
On Error GoTo Err_Command10_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SEARCH"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.RunCommand acCmdFilterByForm
DoCmd.RunCommand acCmdClearGrid

I have tried creating an 'APPLY FILTER' button on my 'SEARCH FORM'. However
is appears to be greyed out when the form is opened and therefore does not
allow the user to apply the filter in this way.

With my current set-up the screen blanks when a record does not exist in the
table.

Any suggestions.
 
G

Guest

Hi Back;
There are a couple of methods you could use.

The first question I have is do you want to add a record and open
the form when you have no records after performing your search.

You can try this if I understand your problem correctly.

Dim intNoOfRecords as Integer

intNoOfRecords = table.RecordCount

If intNoOfRecords = 0 then Exit the sub-routime after displaying a
message.

If intNoOfRecords > 0 Perform your function.

Hope I understood your problem correctly.

Good Luck

Len
 
G

Guest

Len,

Thanks for your feedback.

I do not wish to add a new record. However I would like a message box to
appear to notify the user that the record does exist then when the user
clicks OK on the message box ( if it exists) the main form is opened again.

I hope this is clear to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top