473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Combo box searching

18
I have a database where i am wanting a form to lookup data from one table.

i currently have a combo box used for searching and i am wanting to have a text box display the information relating to the search

how am i able to do this? can someone please help me?
May 23 '07 #1
11 1714
JConsulting
603 Expert 512MB
I have a database where i am wanting a form to lookup data from one table.

i currently have a combo box used for searching and i am wanting to have a text box display the information relating to the search

how am i able to do this? can someone please help me?
what field are you returning?

in the after update event of your combo box

me.mytextbox = dlookup("field","yourtable","[yourfield]=" & me.yourcombo)
May 23 '07 #2
tranzit
18
what field are you returning?

in the after update event of your combo box

me.mytextbox = dlookup("field","yourtable","[yourfield]=" & me.yourcombo)

Thanks for the help. i am using a destination field as the search criteria, when the destination is selected the kilometres from the corresponding fiedld are displayed in the textbox.

i tryed the argument you gave me but it now it tells me that there is no macro named "me".

i am so clueless about what i need to do
May 23 '07 #3
JConsulting
603 Expert 512MB
Thanks for the help. i am using a destination field as the search criteria, when the destination is selected the kilometres from the corresponding fiedld are displayed in the textbox.

i tryed the argument you gave me but it now it tells me that there is no macro named "me".

i am so clueless about what i need to do
you have a form.
your form has a combo box
you put the lookup code I gave you in the combo box's after update event
you put the correct names in?

can you paste in the code you tried?
May 23 '07 #4
tranzit
18
you have a form.
your form has a combo box
you put the lookup code I gave you in the combo box's after update event
you put the correct names in?

can you paste in the code you tried?
here is the code i tryed:

me.Kms = dlookup ("kilometres","New Plymouth","[kilometres] = " & me.Dest)

The name of the combo box is Dest
The name of the text box is Kms
The name of the table is New Plymouth
The name of the fields in the table are destination and kilometres
May 23 '07 #5
JConsulting
603 Expert 512MB
here is the code i tryed:

me.Kms = dlookup ("kilometres","New Plymouth","[kilometres] = " & me.Dest)

The name of the combo box is Dest
The name of the text box is Kms
The name of the table is New Plymouth
The name of the fields in the table are destination and kilometres
me.Kms = dlookup ("kilometres","[New Plymouth]","[kilometres] = " & me.Dest)

so you're returning kilomers by comparing kilometers to Dest?

shouldn't it be [destination] = me.dest??

and is it still giving you an error ? if so, what is it?
May 23 '07 #6
tranzit
18
me.Kms = dlookup ("kilometres","[New Plymouth]","[kilometres] = " & me.Dest)

so you're returning kilomers by comparing kilometers to Dest?

shouldn't it be [destination] = me.dest??

and is it still giving you an error ? if so, what is it?

This is what comes up when i try the form:

Microsoft Access can't find the macro 'me'

the macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved. note that when you enter the macrogroupname.macroname syntax in an argument, you must specify the name the macro's macro group was last saved under.

What does that mean??????
May 23 '07 #7
tranzit
18
This is what comes up when i try the form:

Microsoft Access can't find the macro 'me'

the macro (or its macro group) doesn't exist, or the macro is new but hasn't been saved. note that when you enter the macrogroupname.macroname syntax in an argument, you must specify the name the macro's macro group was last saved under.

What does that mean??????

Thanks for all the help i have now sorted it and it works fine
May 24 '07 #8
JConsulting
603 Expert 512MB
Thanks for all the help i have now sorted it and it works fine
can you post the final solution for everyone?
May 24 '07 #9
tranzit
18
can you post the final solution for everyone?
sure,

in the row source of the combo box i have the following statement:
SELECT [Table].field, [Table].field FROM [table] ORDER BY field;

and in the after update of the combo box i have the following:
Private Sub [combo box]_AfterUpdate()
Me! textbox = Me! combo box.column (1)
End Sub

This allowed me to make a selection from the combo box and it displayed the corresponding data in the text box
May 24 '07 #10
This seems so close to what I am trying to do, but I can't get it to work. I tried to follow the example at the end. I have a table called Regions which has two fields--County and Region. In my LP form I have a combo box called county and a text field called region. The county combo box is selecting a county from a query called "Pick List - County". I want the region field to be automatically populated with the corresponding region number as listed in the County table.

I have this:

SELECT [Pick List - County].county, [Pick List - County].county FROM [Pick List - County] ORDER BY county;

in my row source and it lets me pick the county. I have this:

Private Sub County_AfterUpdate()
Me! region = Me! county.column (1)
End Sub

in the after update. It says Compile Error: Syntax Error.

It seems to me like I should have to reference the Regions table somehow. I played with everything I could find about dlookup, but couldn't get that to work, either. Can anyone help?
Jun 22 '07 #11
I kept trying and finally got this to work. I put this:
SELECT [Regions].county, [Regions].county FROM [Regions] ORDER BY county;
in the row source and this:

Me![Region] = DLookup("[region]", "Regions", "[county] = '" & Me!County & "'")

as the code for after update.
Jun 26 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: mr_burns | last post by:
hi, using javascript, how do i select an option in a combo box? i have tried looking on the internet but dont really know what i should be searching for. what i want to happen is that when a...
5
by: Dalan | last post by:
I have been searching the archives in an effort to discover how to derive a dual use of a single combo box - so far no go. I found the piece below which pretty much represents the usage. To...
3
by: AW | last post by:
Hi all, I have a form (named Offices) with a subform (named Occupants) that connect with the Master/Child Field "office number". I have a combo box that allows a user to pull up a particular...
1
by: John | last post by:
I have a combo box in a form for ContactName and a combo box with CompanyName. I would like to limit the ConactName combo box to just the names associated with CompanyName. Could someone please...
1
by: Will | last post by:
I have a combo box on a form which is based on table tblMachine. On that combo box I have four columns visible MachineNumber, description, location and type. The bound column is the MachineNumber...
1
by: dskillingstad | last post by:
Would appreciate any help I could get I have an unbound search form with various text boxes on it for searching my database. I would like to have a combo box on the search form where the source...
6
by: CindyH | last post by:
Hi Does anyone know how to create a multi column combo box from the same table? Thanks, Cindy
1
by: Leandro RM | last post by:
I´ve got the follow scenario. I load a combobox. like this. combo.DataSource = ds.Tables(0); combo.DisplayMember = "CITY"; combo.ValueMember = "ID_CITY"; after I must that someone find a...
9
by: natwong | last post by:
Hi All, I'm a newbie in terms of Access and some of its functionality . I've been stuck on this problem for a couple days, even after searching the Web, etc. Currently I have five combo boxes...
2
by: shredder249 | last post by:
Hi, I have an "Add New Records To Table" form. In the header of the form there is a combo box (artistsource) which looks up values from a different table (Artist), the value selected by the user is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.