Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding A record

Status
Not open for further replies.

Chance1234

IS-IT--Management
Jul 25, 2001
7,871
US
I have a form (frmsearch) which is used to filter and search another form called frmmain.

filtering is no problem, but im having trouble finishing of my search facility

basicly my search facility on frmsearch works like this

in a textbox they enter what tehy are searching for most likely with wild cards, they press a button and in a listbox below appears what it could be. then what i want them to do is to select a record in that listbox and click another button and it will take them on frmmain to that record


normally when i do thinks like this i use the recordsetclone or if it is a subfomr then the gotorecord command but this time it is a totally seperate form and im having trouble getting it to work

any one help

Chance


 
Have you tried issuing:
DoCmd.OpenForm "frmMain",,,,,,"[PrimaryKeyField] = " & Me!RefNo

This is the basic syntax. If you lookup the OpenForm method in the help file, it should be able to give you the specifics & point you in the right direction... James Goodman
 
nope that dont seem to work , both forms are open at the same time

 
How about calling a function on frmMain which includes a recordsetclone (or similar) from frmSearch & passing in the required variable? In theory the form itself can have a function to fetch a record. So if you call this function from the other form & pass in the value I think it will work...

James Goodman
 
mmmm didnt work,

heres my code, for my search button

Dim sTRsql As String
On Error Resume Next

Select Case Frame0.Value

Case 1
sTRfLD = "CounterpartyID"
Case 2
sTRfLD = "CounterpartyName"
End Select

sTRsql = "SELECT " & sTRfLD & " FROM TBLMAIN WHERE " & sTRfLD & " LIKE '" & Me.Text9.Value & "'"

Me.List13.RowSource = sTRsql


Me.List13.Requery

Forms!frmmain.Form.FILTER = "[" & sTRfLD & "] like '" & Text9.Value & "'"
Forms!frmmain.fRMsUB.Form.FILTER = "[" & sTRfLD & "] like '" & Text9.Value & "'"

Forms!frmmain.FilterOn = True
Forms!frmmain.fRMsUB.Form.FilterOn = True

from that SQL , the listbox is populated

my data source on my frmmain is simply SELECT * FROM Tblmain

where am i going wrong ?
 
Do you have a function on frmMain which actively fetches a specific record?

For this to work you will need such a function, & you will then need to pass in the value which will be the criteria... James Goodman
 
Hi!

Maybe you can set the focus back to the main form from the search form and use the Activate event procedure to run the code to find the record. Of course, you will need to reference the information from the search form so you will need to build in a check(or some error trapping) in case the search form isn't open. All in all, I think it is easier to close the main form when going to the search form and reopen it with the filter applied.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top