A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

text box lookup to list box



 
 
Thread Tools Display Modes
  #11  
Old September 1st, 2009, 11:09 PM posted to microsoft.public.access.gettingstarted
Raymond[_8_]
external usenet poster
 
Posts: 24
Default text box lookup to list box

I too should read them before posting, It does NOT work right...
I've even tried combo boxes. Here is my intent maybe it will help.
The user will type in a tag number and find maybe 25 listings in date and
time order of the same tag, he will double click the record that relates to
his letter, that will then add this log data into a violation table so he can
get a speeding or parking ticket. This person will not be adding records to
this table just searching for the right one. If he found him parked illegally
on Sept. 1st He needs to verify he entered the gate on Sept 1st. Not from
July 25th.

--
Thanks again, Why are so many access experts in Great Britian? lol
Ray J


"Wayne-I-M" wrote:

Glad you got it working.

--
Wayne
Manchester, England.



"Raymond" wrote:

oh, I did use License_tag_number instead of ID but left the brackets

Private Sub txtSearchReg_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[License_tag_number] = " & Str(Nz(Me![txtSearchReg], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.License_Tag_Number.SetFocus
Me.txtSearchReg = ""
End Sub

--
Ray J


"Raymond" wrote:

Thanks for helping Wayne
I set up the two forms and added this to the text boxes after update event
but it does not display the searched record in the list box/form 2 below
My field name is License Tag Number in the table and I renamed my text box
to SearchReg for ease.

Private Sub txtSearchReg_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![txtSearchReg], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.License_Tag_Number.SetFocus
Me.txtSearchReg = ""
End Sub

They are bound.

--
Ray J


"Wayne-I-M" wrote:

Ok thats not too difficult.

You need 2 forms
frm1 - format singl form
This will be based on a table or query that holds the details of the cars

frm2 - format continous form
This will be based on the times that all cars entered the car park

Link the 2 forms on the reg number.

I assume that you have a table with
IDfield
RegNumber
plus other details of the car (this is what frm1 will be based on)

Add and inbound to frm1
Use something like this on the AfterUpdate of the text box (I assume the
text box is called txtSearchReg)

Private Sub txtSearchReg_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![txtSearchReg], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.RegNumberField.SetFocus
Me.txtSearchReg = ""
End Sub


Now this will do what you want - but ;-)
If you added a combo box insead of using a text box - rember that you can
just type the reg number into a combo just as simply as a text box you can
set the expend to yes - which users like plus you could add something like
this to the combo
The same code as above to find the record
Plus
This will inform the users if they type in the wrong reg number or (if the
number is correct but the reg is not in the database ) give the option to add
a new reg
I would suggest you use a combo - but up to you


Private Sub txtSeachReg_NotInList(NewData As String, Response As Integer)
Dim Db As DAO.Database
Dim rs As DAO.Recordset
Dim msg As String
msg = "'The reg you typed in - " & NewData & "' is not on file." & vbCr & vbCr
msg = msg & "Do you want to add a new car reg to the file?"
If MsgBox(msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "OK then try again."
Else
Set Db = CurrentDb
Set rs = Db.OpenRecordset("ADDTableNameHere", dbOpenDynaset)
rs.AddNew
rs![ADDRegField] = NewData
rs.Update
Response = acDataErrAdded
End If
End sub

Plus there is lots of other useful stuff you can do
Of course you can also do these with a text box - but more with combos

Hope this helps a little

Top Tip - use a combo to search for a record not a text box ?



--
Wayne
Manchester, England.



"Raymond" wrote:

Hi Wayne, Thanks for your reply. History or use info
I have a table of vistors by license plate, where when etc...
Desire is to type a tag number into a text box and the list below will list
all the times that car came into the park. The user can then click the
specific time/record and generate a letter(my next step, sub form). I used
the combo box you suggested but knowing the users I dont think that will
work.

I have an unbound text box to type in the plate number and wanted to use a
search command button to click, desired results would show in the list box
below.

Thougts? Thanks a bunch from Florida
Cheers


--
Ray J


"Wayne-I-M" wrote:

Hi Raymond

You can do this quite simply with a little code on your form's text box
afterUpdate event. But, (as you say you are new to access) can I suggest
that you design a form that displays all the records that you may want to to
search and then use the wizard to create a Combo Box and set the options on
the wizard to
Find a record on my form.

If this is not suitable for your uses then post back as most people will be
able to give you some help with the code.

Hope this helps

--
Wayne
Manchester, England.



"Raymond" wrote:

newbi user, trying to enter text in a text box (on a form) to find a record
in the database and display the records in a list box below on the same form.
Can anyone help. Thanks
--
Ray J

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.