473,805 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with form-combo boxes populating other fields.

5 New Member
I am trying to create a from that the user can select a street from a combo box (named street), then pick a second street from another combo box, containing only valid cross streets(named Cross). When the second combo box is completed I want a third control, a text box (named ID)to be filled in with a id for that intersection.

I have a table that contains the fields:
Fr--street name
To--cross street name
Node--The unique id for the intersection (this is only unique in that it describes a single point in space, not a unique record)

This table contains duplicates, i.e.:
Fr ______________T o _____________ Node
8 ST NW ________2 AVE NW________101
2 AVE NW________8 ST SW __________101

It is possible that more than 2 records could have the same Node
I do not maintain the database that the table is created from and cannot change the design of the table in any way; I can however run any queries, or make tables to manipulate the data.

I have a form and am able to get the first combo box (Street) to work, and the second combo box (cross) to provide a list of only valid cross streets.

The problem is I cannot get the third control (ID) to populate with the value for node.
The closest I can get is
Expand|Select|Wrap|Line Numbers
  1. Private Sub cross_AfterUpdate()
  2. id = "select node from intlist where street.value=fr and cross.value=to"
  3. End Sub 
This only populates the ID field with a direct quote of the sql statement.

I have no idea where to go from here
Any help would be greatly appreciated.

I am working with access 2003 and windows xp professional.
Jul 19 '07 #1
5 1805
Scott Price
1,384 Recognized Expert Top Contributor
A couple of questions, what are the names of your combo boxes that choose the street and cross? One naming convention that makes it (MUCH) easier to write code is to prefix these with cbo...

It looks like in your SQL statement you are transposing the values that you are needing to use as criteria: i.e. fr needs to be equal to the value of your combo box street, not the other way around, also a little syntax correction is called for.

First of all you should to assign the value of your SQL statement to a variable first, instead of directly to the value of the combo box. Try changing this:
Expand|Select|Wrap|Line Numbers
  1.          Private Sub cross_AfterUpdate()
  2.          id = "select node from intlist where street.value=fr and cross.value=to"
  3.          End Sub
State your variables at the top of the code window immediately under Option Explicit...
Expand|Select|Wrap|Line Numbers
  1. Private Const strSQL1 = "SELECT node" & " FROM intlist WHERE fr = ' "
  2. Private Const strSQL2 = " ' AND to = "
  3. Private strSQL As String
Then in your AfterUpdate event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cross_AfterUpdate()
  2. strSQL = strSQL1 & Me!street.Value & strSQL2 & Me!cross.Value
  3. Me!id.Value = strSQL
  4. Me!id.Requery
  5. End Sub
You may not need the Requery method at the end, but try it first with, then if it throws up, comment that part out by prefixing with an '

Hope this helps!

Regards,
Scott
Jul 19 '07 #2
Scott Price
1,384 Recognized Expert Top Contributor
Something urgent has come up here, and I won't be able to get back to this thread until at least Monday. If you have more problems, post back here and hopefully one of the others will be able to take it from there.

I'll try to check in on Monday and see the progress. If you haven't had any more problems, and the fix has worked, please post here to let me know!

Thanks,
Scott
Jul 19 '07 #3
a Wellner
5 New Member
Ok

I took your suggestion and changed the names of the combo boxes to be prefixed by “cbo”. I am just learning VBA and SQL but I think I understand everything..

“It looks like in your SQL statement you are transposing the values that you are needing to use as criteria: i.e. fr needs to be equal to the value of your combo box street, not the other way around, also a little syntax correction is called for.”

So I need to list the field in my table first then the value that I want to compare it to.

I understand what you are saying about using variables, and changed the code to what you posted, now when I select values in the combo boxes I get something like this:
“select node from intlist where fr=1 AVE NE and to=1 ST NE”

I was able to get something like this before, however not with the street names listed, but I still need to get the actual value for the node.

Thank you for your help
Jul 19 '07 #4
Scott Price
1,384 Recognized Expert Top Contributor
Hello, I've just snatched a few minutes to work on this.

I set up in my test database a table called tblIntList with this structure:
Expand|Select|Wrap|Line Numbers
  1. IntID  AutoNumber PK
  2. iTo  Text
  3. iFrom  Text
  4. Node  Number
I then created a form based on this table. In the detail section of the form I left one text box visible called Node. The other text boxes with IntID, iTo and iFrom I made invisible (the last two weren't necessary for my purposes but may be for yours). I then created a select query called qryIntersection . In this query I chose to display the field IntID, then in the next field I gave it a custom name by entering the following: Intersection: [iTo] & ", " & [iFrom]

In the header section of this form I created a combo box called cboIntersection . I left this box unbound, but the Row Source field I set to qryIntersection ... I made it have 2 columns, the column sizes are 0",2", the bound column is 1, and the Limit to List is set to Yes.

Then in the AfterUpdate event of this combobox, I wrote this code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cboIntersection_AfterUpdate()
  2. IntTo = Me!cboIntersection.Value
  3. DoCmd.GoToRecord , , acGoTo, IntTo
  4. End Sub
This worked for me making the Node text box show up the value for the corresponding intersection.

I'm sorry that I won't be able to check back in on this Monday, I won't be back to my computer until probably Tuesday evening. Thought I'd throw this at you to see if it could help...

Regards,
Scott
Jul 22 '07 #5
Scott Price
1,384 Recognized Expert Top Contributor
BTW "To" is a reserved word in Access and Visual Basic, you should rename your field to something different so as to avoid confusing the poor computer :-)
Jul 22 '07 #6

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

Similar topics

3
3273
by: laurie | last post by:
Hi all, I'm trying to help out a friend who has inherited a client with a PHP shopping cart application. Neither of us know PHP, but I've been muddling my way through, trying to get these old scripts working on a new server with the most recent version of PHP. I've pretty much taken care of all the various errors that were popping up. Most only pointed out out non-fatal undefined or assumed variables. I've been able to cure most of...
1
1838
by: GrelEns | last post by:
hello, i had a trouble with re that i didn't understand (this is a silly example to show, to parse html i use sgmllib) : having this string : >>> s = """<form name="test" method="post" action="test.php"> <input type="text" name="title" size="1." value="test..."> <br> <a href="help.php">help</a>
5
3008
by: Craig Keightley | last post by:
Please help, i have attached my page which worksin IE but i cannnot get the drop down menu to fucntion in firefox. Any one have any ideas why? Many Thanks Craig <<<<<<<<<<<<<<CODE>>>>>>>>>>>>>>>> <html>
2
3308
by: chanchito_cojones | last post by:
hi there, I am needing some help with a database I am putting together. The database works off of a main Form, which then has buttons on it that will open up other forms. The problem I am having is that if I am updating any information on the current record, and then open one of the other forms, the new form will not show the updated information. I realize that a simple macro solves this problem by basically closing the first form,...
5
2619
by: TD | last post by:
Hey All, I am hooking up our custom html (.chm) help file to our Access xp application, and, despite reading several posts and manuals on this, I still have a gap in my understanding... OK, so I've setup the registry keys to have a profile and I specify an AppHelpFile and TitleBar in that profile. This works swell: when I startup my application in runtime with the /profile option and then I press F1 on a form, our help file appears....
1
1980
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following statement. Help.ShowHelp(Parent:=Me, url:=Me.HELP_URL_PRE & Me.myWorker.HelpFile) How do I get it to go away when the program exits? Now when I quit the program that I called it form the help file is sill displayed. Is there a way to get a handle...
10
2544
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 TeamScore(1-10) Employee3 TeamScore(1-10) Employee4 TeamScore(1-10) Then I submit this page with all the values in TeamScore for every employee and I want to perform a calculation based on the values in the drop-down and a
9
8030
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-)) When I set the label with "SendToBack", it completely disapears. I also tried to set the child form like "BringToFront" but this also does not help.
5
1831
by: pattersonc | last post by:
Hello! I'm new to this forum and also new to using ASP and SQL and Access. I am in need of some help. I'm trying to make a database to help my football team. I've pretty much got the whole thing done to where a coach can enter new games and various plays within those games. Now I've reached the hard part. I need to make a process page that will help me query the database given varying situations. Below is an image of the page that the...
1
3210
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the code for attachment, I am not able to send anything. I get blank email. Can you please help me on this? Here is the html form:
0
9596
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.