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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code help for navigational buttons 2

Status
Not open for further replies.

MA04

Technical User
Dec 21, 2004
162
GB
Hi guys,

I have 2 forms say form1 and form2. Now in form1 the user enters a code in a textbox say EnterCodeTxt, now if that record is already present in a table say table1 then a command box is activated and the user can press it to view the existing record. The command box opens form2 and some texboxes on form2 use Dlookup to dislay the existing record

i.e. Me.ATextboxName = DLookup("Field", "Table1", "Code='" & Forms![Form1]![EnterCodeTxt] & "'")

Now the problem
If the code entered by the user is in more then 1 record, i need a way to allow the user to move through the records. I have made command buttons for navigational purposes, i.e. GoToNext, GoToPrevious, but have not been able to get them to work. Because i am using dlookup to open the records.

I need code for command buttons GoToNext, GoToPrevious to do as the name states, to records being displayed on textboxes on form2. I need a way to loop through the records and display them using dlookup, possibly?

Hope that makes sense, thanks in advance for any help,

M-.
 
Why not bind Form2 to the table and use the Filter and FilterOn properties ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi
I think you need to use:
DoCmd.OpenForm Form2, , , "Code = '" & Me!EnterCodeTxt & "'"

This would go in the AfterUpdate event. It takes advantage of Where for opening the form and should select all matching records.
 
Thanks for the reply PH, the thing is the form will be used when a enquier phones, the user then enters his details and adds record to table, but before this happens the user enters the enquier postcode if it exist a command button is activated and the user can view his/her details. Now the thing is i can bind the form and open it with a query with criteria as my EnterCodeTxt but it slows the process down.

I was hoping for a way to speed up process as quick as possible.

Thanks for that Remou i will give it a go,

M-.
 
DLookUp calls are faster than a filtered bound form ?
 
I thought they were because i had my Form2 unbound and the dlookup called the fields, I guess I may have got the illusion of speed?

However i have bound the form as you suggested PH and done something similar to Remou's code it works and does not appear to be too slow thanks again,

M-.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top