Help with Macro?

R

Randy

I am running the following macro that opens a case number. Field is
called number. If the number exists I want it to open the form. I do
not want it to go to the form if the worker puts in a number that does
not exist. Right now it will open the form to a blank record.

How can I fix this?

Private Sub Command31_Click()
On Error GoTo Err_Command31_Click


DoCmd.GoToRecord , , acFirst

Exit_Command31_Click:
Exit Sub

Err_Command31_Click:
MsgBox Err.Description
Resume Exit_Command31_Click

End Sub
 
K

Ken Snell [MVP]

What you posted is not an ACCESS macro... macros in ACCESS are not VBA code
(other Office applications do use the term macro for VBA code, which causes
confusion...). Your question would be more appropriate for one of these
newsgroups:
microsoft.public.access.modulescoding
microsoft.public.access.modulesdaovba
microsoft.public.access.formscoding

Your description of "open the form" does not match what you've posted as the
code that you're running. The posted code will simply move the form to the
first record in the form's RecordSource. It does not look to see what "case
number" may have been entered by a user.

You'll need to post more details about what controls are on the form, what
the user is expected to do, and which "form" you're wanting to open.
 
R

Randy

Sorry Ken I am new to Access and just trying to learn.

This is the macro

OPENFORM

Form Name = Main Employments
View = Form
Filter Name =FINDNUMBER
Where Condition =
Data Mode =Edit
Window Mode =Normal

I am not sure what condition to use.
 

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

Top