Find Record in Form

G

Guest

Hello,

I would like to place a button in a form to allow users to search in a
different form for records that meet certain criteria.

I know that you can create the button in the same form you would like to
search, but I would like to do it this way. Is this possible?

Example:
User would enter a work order number on a form, called FindWorkOrderForm,
then click the button.

Then, the form called ScheduleForm would open and they would see the record
that had the work order number they entered in the other form.


Thanks,
Emily
 
F

fredg

Hello,

I would like to place a button in a form to allow users to search in a
different form for records that meet certain criteria.

I know that you can create the button in the same form you would like to
search, but I would like to do it this way. Is this possible?

Example:
User would enter a work order number on a form, called FindWorkOrderForm,
then click the button.

Then, the form called ScheduleForm would open and they would see the record
that had the work order number they entered in the other form.

Thanks,
Emily

Add the combo box to Form1.
Set the Bound Column to whatever column displays the WorkOrder value.
Add a command button to Form1.
Code the Command Button's Click event:
DoCmd.OpenForm "Form2", , , "[WorkOrder] = " & Me.ComboName

The above assumes [WorkOrder] is a Number datatype

If [WorkOrder] is Text datatype, then use:
"[WorkOrder] = '" & Me.ComboName & "'"
 
G

Guest

Thank you for your reply, but I do not want to use a combo box. I would like
to use a text box to type values into.

Can I use this code if I leave the textbox as is?

DoCmd.OpenForm "Form2", , , "[WorkOrder] = '" & Me.ComboName & "'"

WorkOrderNumber is a text field.

The error I got when I tried to input a number was: "Can't find the macro
'DoCmd' "

What can I do to fix this?

Thanks again.
fredg said:
Hello,

I would like to place a button in a form to allow users to search in a
different form for records that meet certain criteria.

I know that you can create the button in the same form you would like to
search, but I would like to do it this way. Is this possible?

Example:
User would enter a work order number on a form, called FindWorkOrderForm,
then click the button.

Then, the form called ScheduleForm would open and they would see the record
that had the work order number they entered in the other form.

Thanks,
Emily

Add the combo box to Form1.
Set the Bound Column to whatever column displays the WorkOrder value.
Add a command button to Form1.
Code the Command Button's Click event:
DoCmd.OpenForm "Form2", , , "[WorkOrder] = " & Me.ComboName

The above assumes [WorkOrder] is a Number datatype

If [WorkOrder] is Text datatype, then use:
"[WorkOrder] = '" & Me.ComboName & "'"
 
F

fredg

Thank you for your reply, but I do not want to use a combo box. I would like
to use a text box to type values into.

Can I use this code if I leave the textbox as is?

DoCmd.OpenForm "Form2", , , "[WorkOrder] = '" & Me.ComboName & "'"

WorkOrderNumber is a text field.

The error I got when I tried to input a number was: "Can't find the macro
'DoCmd' "

What can I do to fix this?

Thanks again.
fredg said:
Hello,

I would like to place a button in a form to allow users to search in a
different form for records that meet certain criteria.

I know that you can create the button in the same form you would like to
search, but I would like to do it this way. Is this possible?

Example:
User would enter a work order number on a form, called FindWorkOrderForm,
then click the button.

Then, the form called ScheduleForm would open and they would see the record
that had the work order number they entered in the other form.

Thanks,
Emily

Add the combo box to Form1.
Set the Bound Column to whatever column displays the WorkOrder value.
Add a command button to Form1.
Code the Command Button's Click event:
DoCmd.OpenForm "Form2", , , "[WorkOrder] = " & Me.ComboName

The above assumes [WorkOrder] is a Number datatype

If [WorkOrder] is Text datatype, then use:
"[WorkOrder] = '" & Me.ComboName & "'"

Yes you can enter the value in a text control.
Just use the text control's name in the code.
See below.

(Note: The problem with using a text control is that the user can
inadvertently enter an incorrect value.
Using a Combo box with all of the WorkOrder values, limits the user to
merely selecting a value, not having to remember the exact value. Much
easier and quicker, especially if using the Combo AutoExpand feature.)

From the error message you received, I would guess you entered the
above code directly on the property sheet's On Click line.
That's not where it goes.

Here is how to write code.

Open the Form in Design View.
Select the Command Button.
Display the Command Button's Property sheet.
Click on the Event tab.
On the line that says On Click, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write, all on one line:

DoCmd.OpenForm "Form2", , , "[WorkOrder] = '" & Me.TextControlName &
"'"

Save the changes.

Change "Form2", [WorkOrder] and [TextControlName] to whatever the
actual Form, Field and Control names are.
 
G

Guest

fredg said:
Thank you for your reply, but I do not want to use a combo box. I would like
to use a text box to type values into.

Can I use this code if I leave the textbox as is?

DoCmd.OpenForm "Form2", , , "[WorkOrder] = '" & Me.ComboName & "'"

WorkOrderNumber is a text field.

The error I got when I tried to input a number was: "Can't find the macro
'DoCmd' "

What can I do to fix this?

Thanks again.
fredg said:
On Tue, 30 Oct 2007 08:43:04 -0700, Emily wrote:

Hello,

I would like to place a button in a form to allow users to search in a
different form for records that meet certain criteria.

I know that you can create the button in the same form you would like to
search, but I would like to do it this way. Is this possible?

Example:
User would enter a work order number on a form, called FindWorkOrderForm,
then click the button.

Then, the form called ScheduleForm would open and they would see the record
that had the work order number they entered in the other form.

Thanks,
Emily

Add the combo box to Form1.
Set the Bound Column to whatever column displays the WorkOrder value.
Add a command button to Form1.
Code the Command Button's Click event:
DoCmd.OpenForm "Form2", , , "[WorkOrder] = " & Me.ComboName

The above assumes [WorkOrder] is a Number datatype

If [WorkOrder] is Text datatype, then use:
"[WorkOrder] = '" & Me.ComboName & "'"

Yes you can enter the value in a text control.
Just use the text control's name in the code.
See below.

(Note: The problem with using a text control is that the user can
inadvertently enter an incorrect value.
Using a Combo box with all of the WorkOrder values, limits the user to
merely selecting a value, not having to remember the exact value. Much
easier and quicker, especially if using the Combo AutoExpand feature.)

From the error message you received, I would guess you entered the
above code directly on the property sheet's On Click line.
That's not where it goes.

Here is how to write code.

Open the Form in Design View.
Select the Command Button.
Display the Command Button's Property sheet.
Click on the Event tab.
On the line that says On Click, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write, all on one line:

DoCmd.OpenForm "Form2", , , "[WorkOrder] = '" & Me.TextControlName &
"'"

Save the changes.

Change "Form2", [WorkOrder] and [TextControlName] to whatever the
actual Form, Field and Control names are.

I followed your instruction as best I could, but now I am getting new error
messages. I think this might be related to the [textcontrolname]. What is
that? If it is just the name of the unbound textbox, I tried that and it
didn't work.

The error message highlights the textformcontrol part of the code and says
"method or data member not found"

How can I fix this?

Thanks so much,
Emily
 

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