Search for a Record

  • Thread starter Thread starter Robert Sykes
  • Start date Start date
R

Robert Sykes

I have 2 tables, a customer information table and a table for the customers
trouble tickets, the tables are related to each other using the CustID field
from the Customers table (CustID is the field in the Customers table, Cust
is the field name in the trouble tickets table). I have 2 forms built, one
that is based off the trouble ticket table (frmtrbtic) and one is based on
the Customers table (frmcustinfo). On frmcustinfo I have a unbound control
that I want to use to searching, I have 2 questions in regards to this:

1) What event type (i.e onclick, afterupate etc) do I use to allow a user to
put the ticket number into the unbound control and hit enter to start the
search.

2) How do I code it so it will open both the form frmtrbtic and find the
correct customer for frmcustinfo.

Hope this makes sense.
 
Rober,

Here is a piece of code from a button that i use. All you
need is to put in your variables and criteria, I would
use the OnLostFocus to run it. So this goes in the event
procedure, change the names to protect the inocent.

Good Luck.
Private Sub JobNumberButton_Click()
On Error GoTo Err_JobNumberButton_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BidInformationForm"

stLinkCriteria = "[TaurusJobNumber]=" & "'" & Me![job
numbercombo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_JobNumberButton_Click:
Exit Sub

Err_JobNumberButton_Click:
MsgBox Err.Description
Resume Exit_JobNumberButton_Click

End Sub
 
Lets give it a shot and see shall we, since my vb skills are very rough lets
see what I can cobble together.


kevin watkins said:
Rober,

Here is a piece of code from a button that i use. All you
need is to put in your variables and criteria, I would
use the OnLostFocus to run it. So this goes in the event
procedure, change the names to protect the inocent.

Good Luck.
Private Sub JobNumberButton_Click()
On Error GoTo Err_JobNumberButton_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BidInformationForm"

stLinkCriteria = "[TaurusJobNumber]=" & "'" & Me![job
numbercombo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_JobNumberButton_Click:
Exit Sub

Err_JobNumberButton_Click:
MsgBox Err.Description
Resume Exit_JobNumberButton_Click

End Sub
-----Original Message-----
I have 2 tables, a customer information table and a table for the customers
trouble tickets, the tables are related to each other using the CustID field
from the Customers table (CustID is the field in the Customers table, Cust
is the field name in the trouble tickets table). I have 2 forms built, one
that is based off the trouble ticket table (frmtrbtic) and one is based on
the Customers table (frmcustinfo). On frmcustinfo I have a unbound control
that I want to use to searching, I have 2 questions in regards to this:

1) What event type (i.e onclick, afterupate etc) do I use to allow a user to
put the ticket number into the unbound control and hit enter to start the
search.

2) How do I code it so it will open both the form frmtrbtic and find the
correct customer for frmcustinfo.

Hope this makes sense.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.657 / Virus Database: 422 - Release Date: 13/04/2004


.
 
1. You could create a comand button and set it as the default button (set
the Default Property to "Yes" for that button) , that way when the user
presses <enter> the On Click event for the default button would be executed.
The user could then fill in the ticket number and then press <Enter> or
click on the button, either way.

2. Activate the second form in the On Click event of the button as described
above:
DoCmd.OpenForm pFormName
Then execute a method that performs your search, also in the On Click event
described above.

Bill Nicholson
Access Dufus
 
Thanks for the tip, but I don't really want another button on the form, but
if that's what it comes down to then so be it. I can get the ticket to open,
that was no problem, but what's a little bit beyond my ability is to find
the customer record that 'owns' the ticket.
 
Back
Top