473,602 Members | 2,846 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Combo Box from a Text Box Help

I am trying to make a combo box dependent on a text box. I cannot get
the combo box to pull the related data from the text box. I have been
all over this user group & have tried several versions of code to no
avail.

I would like to display all contact names (in the combo box) related
to the customer number in the text box.

Here's what I have:

Table: TOrdAck
Fields: OACustID, OAContact

Table: TCust
Fields: CustID, CompanyID, CompanyName

Note: The OACustID and the CustID establishes the relationship between
the two tables.

Query: QCust
Fields: TOrdAck. OACustID, TOrdAck.OAConta ct, TCust.CustID,
TCust.CompanyID

Form name: FOACust
Record Source: QCust

Textbox Name: CustID
Control Source: OACustID

Control Box Name: Combo78
Row Source Type: Table/Query
Row Source: <empty>

In the After Update event in my textbox CustID, I have the following
code:
*************** ****
Private Sub CustID_AfterUpd ate()

Dim strSQL As String
strSQL = "Select " & Me!CustID
strSQL = strSQL & " from TOrdAck"
Me!Combo78.RowS ourceType = "Table/Query"
Me!Combo78.RowS ource = strSQL

Me!Combo78.Requ ery

End Sub
*************** *****
I would like to have the combo box display any OAContacts that match
the CustID. All I get is a blank combo box even if there are multiple
contact names that match the CustID.

I have also tried the following code, but get the same result:

*************** *****
Private Sub CustID_AfterUpd ate()

Me!Combo78.RowS ource = "SELECT [OAContact],[OACustID] FROM [QCust]
WHERE_
"[OACustID] =" & Me!CustID & " ORDER BY [OAContact];"

Me!Combo78.Requ ery

End Sub
*************** ****

Any suggestions? I'm a novice at VBA so any detail you can provide
will be appreciated.

Thanks

Jun 13 '07 #1
4 3022
On Wed, 13 Jun 2007 13:56:33 -0700, Swinky <sw********@lun t.com>
wrote:

It appears your sql statement for the combobox is wrong. Create it
first as a query, then switch to SQL view to see what the sql
statement should look like. Initially you'll put a test customernumber
as the criteria.
Temporarily bind this query to your combobox, and make sure you have
the column count and width set correctly.

Then, smarter still, in your query refer back to the textbox to pick
up the customernumber using syntax like:
=Forms!FOACust! CustID
for the criteria.

If you're lucky you end up with a solution entirely created at design
time, and not a single line of code. Even .Requery may not be needed.

-Tom.

>I am trying to make a combo box dependent on a text box. I cannot get
the combo box to pull the related data from the text box. I have been
all over this user group & have tried several versions of code to no
avail.

I would like to display all contact names (in the combo box) related
to the customer number in the text box.

Here's what I have:

Table: TOrdAck
Fields: OACustID, OAContact

Table: TCust
Fields: CustID, CompanyID, CompanyName

Note: The OACustID and the CustID establishes the relationship between
the two tables.

Query: QCust
Fields: TOrdAck. OACustID, TOrdAck.OAConta ct, TCust.CustID,
TCust.CompanyI D

Form name: FOACust
Record Source: QCust

Textbox Name: CustID
Control Source: OACustID

Control Box Name: Combo78
Row Source Type: Table/Query
Row Source: <empty>

In the After Update event in my textbox CustID, I have the following
code:
************** *****
Private Sub CustID_AfterUpd ate()

Dim strSQL As String
strSQL = "Select " & Me!CustID
strSQL = strSQL & " from TOrdAck"
Me!Combo78.RowS ourceType = "Table/Query"
Me!Combo78.RowS ource = strSQL

Me!Combo78.Requ ery

End Sub
************** ******
I would like to have the combo box display any OAContacts that match
the CustID. All I get is a blank combo box even if there are multiple
contact names that match the CustID.

I have also tried the following code, but get the same result:

************** ******
Private Sub CustID_AfterUpd ate()

Me!Combo78.RowS ource = "SELECT [OAContact],[OACustID] FROM [QCust]
WHERE_
"[OACustID] =" & Me!CustID & " ORDER BY [OAContact];"

Me!Combo78.Requ ery

End Sub
************** *****

Any suggestions? I'm a novice at VBA so any detail you can provide
will be appreciated.

Thanks
Jun 14 '07 #2
Hi,
What is the datatype of OACustID and CustID???
Did you try building this in a query first to ensure it works?
bobh.

On Jun 13, 4:56 pm, Swinky <swinkel...@lun t.comwrote:
I am trying to make a combo box dependent on a text box. I cannot get
the combo box to pull the related data from the text box. I have been
all over this user group & have tried several versions of code to no
avail.

I would like to display all contact names (in the combo box) related
to the customer number in the text box.

Here's what I have:

Table: TOrdAck
Fields: OACustID, OAContact

Table: TCust
Fields: CustID, CompanyID, CompanyName

Note: The OACustID and the CustID establishes the relationship between
the two tables.

Query: QCust
Fields: TOrdAck. OACustID, TOrdAck.OAConta ct, TCust.CustID,
TCust.CompanyID

Form name: FOACust
Record Source: QCust

Textbox Name: CustID
Control Source: OACustID

Control Box Name: Combo78
Row Source Type: Table/Query
Row Source: <empty>

In the After Update event in my textbox CustID, I have the following
code:
*************** ****
Private Sub CustID_AfterUpd ate()

Dim strSQL As String
strSQL = "Select " & Me!CustID
strSQL = strSQL & " from TOrdAck"
Me!Combo78.RowS ourceType = "Table/Query"
Me!Combo78.RowS ource = strSQL

Me!Combo78.Requ ery

End Sub
*************** *****
I would like to have the combo box display any OAContacts that match
the CustID. All I get is a blank combo box even if there are multiple
contact names that match the CustID.

I have also tried the following code, but get the same result:

*************** *****
Private Sub CustID_AfterUpd ate()

Me!Combo78.RowS ource = "SELECT [OAContact],[OACustID] FROM [QCust]
WHERE_
"[OACustID] =" & Me!CustID & " ORDER BY [OAContact];"

Me!Combo78.Requ ery

End Sub
*************** ****

Any suggestions? I'm a novice at VBA so any detail you can provide
will be appreciated.

Thanks

Jun 14 '07 #3
On Jun 13, 8:13 pm, Tom van Stiphout <no.spam.tom7.. .@cox.netwrote:
On Wed, 13 Jun 2007 13:56:33 -0700, Swinky <swinkel...@lun t.com>
wrote:

It appears your sql statement for the combobox is wrong. Create it
first as a query, then switch to SQL view to see what the sql
statement should look like. Initially you'll put a test customernumber
as the criteria.
Temporarily bind this query to your combobox, and make sure you have
the column count and width set correctly.

Then, smarter still, in your query refer back to the textbox to pick
up the customernumber using syntax like:
=Forms!FOACust! CustID
for the criteria.

If you're lucky you end up with a solution entirely created at design
time, and not a single line of code. Even .Requery may not be needed.

-Tom.
OK, so I'm getting closer. I did as suggested...cre ated a query,
tested it & copied the SQL to the combo box Row Source & changed the
query criteria for the CustID field to =Forms!FOACust! CustID.

Complete SQL is:
*************** **
SELECT TOrdAck.OANo, TOrdAck.OACustI D, TOrdAck.OAConta ct, TCust.CustID
FROM TCust RIGHT JOIN TOrdAck ON TCust.CustID=TO rdAck.OACustID WHERE
(((TOrdAck.OACo ntact) Is Not Null) And ((TCust.CustID) =Forms!FOACust!
CustID));
*************** ***

All works well, EXCEPT that when I click on the combo box, I get the
following:
-------------------------------------
Enter Parameter Value:

FOACust!CustID
-------------------------------------
So the CustID number is not getting passed to the combo box. :(

The combo box is really on a subform of my main form "FOAtabSear ch".
So I tried the above code changing it to =Forms!FOAtabSe arch!FOACust!
CustID but still get the same Parameter Value message box.

Any ideas why CustID is not getting passed to the combo box? When I
view the form, it definately is populated with the CustID before I
click the combo box and get the parameter request.

BTW, both the CustID and the OACustID are set to text.


Jun 14 '07 #4
On Thu, 14 Jun 2007 08:13:28 -0700, Swinky <sw********@lun t.com>
wrote:

=Forms!FOAtabSe arch!FOACust!Cu stID should be changed to:
=Forms!FOAtabSe arch!FOACust.Fo rm!CustID
Why?
I think of it as:
=Forms!FOAtabSe arch: this is my parent form.
=Forms!FOAtabSe arch!FOACust: this is the subform CONTROL on the parent
form.
=Forms!FOAtabSe arch!FOACust.Fo rm: this is the subform in the subform
control.

-Tom.
>On Jun 13, 8:13 pm, Tom van Stiphout <no.spam.tom7.. .@cox.netwrote:
>On Wed, 13 Jun 2007 13:56:33 -0700, Swinky <swinkel...@lun t.com>
wrote:

It appears your sql statement for the combobox is wrong. Create it
first as a query, then switch to SQL view to see what the sql
statement should look like. Initially you'll put a test customernumber
as the criteria.
Temporarily bind this query to your combobox, and make sure you have
the column count and width set correctly.

Then, smarter still, in your query refer back to the textbox to pick
up the customernumber using syntax like:
=Forms!FOACust !CustID
for the criteria.

If you're lucky you end up with a solution entirely created at design
time, and not a single line of code. Even .Requery may not be needed.

-Tom.

OK, so I'm getting closer. I did as suggested...cre ated a query,
tested it & copied the SQL to the combo box Row Source & changed the
query criteria for the CustID field to =Forms!FOACust! CustID.

Complete SQL is:
************** ***
SELECT TOrdAck.OANo, TOrdAck.OACustI D, TOrdAck.OAConta ct, TCust.CustID
FROM TCust RIGHT JOIN TOrdAck ON TCust.CustID=TO rdAck.OACustID WHERE
(((TOrdAck.OAC ontact) Is Not Null) And ((TCust.CustID) =Forms!FOACust!
CustID));
************** ****

All works well, EXCEPT that when I click on the combo box, I get the
following:
-------------------------------------
Enter Parameter Value:

FOACust!Cust ID
-------------------------------------
So the CustID number is not getting passed to the combo box. :(

The combo box is really on a subform of my main form "FOAtabSear ch".
So I tried the above code changing it to =Forms!FOAtabSe arch!FOACust!
CustID but still get the same Parameter Value message box.

Any ideas why CustID is not getting passed to the combo box? When I
view the form, it definately is populated with the CustID before I
click the combo box and get the parameter request.

BTW, both the CustID and the OACustID are set to text.
Jun 15 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
943
by: Ron | last post by:
I am new to .NET and am trying to build a little prototype web app that deals with information about loans. I have been reading several books, which has been helpful, but I am having a terrible time getting changes to a dataset posted back to the SQL database table (named "tblGeneral"). The app has a combo box that is populated by a SQLDataAdapter and DataSet. When the user makes a selection in the combo box, a second SQLDataAdapter is...
1
5422
by: OhFiddleSticks | last post by:
Does anyone know if there is a way to add a text value to a combo box (the text box part, not the rowsource) in VBA without triggering an update event? I've tried everything I can think of without success. What I want is a combo box that I set the rowsource for in VBA and requery it, then it drops down, and enters a probable selection that may or may not already be in the list to the text box portion. Then I can manually compare the...
1
2303
by: Burghew | last post by:
Hi all, I have 3 unbound combo boxes in my form which basically helps me to filter for values. I need to update a text box which will be stored with the value I receive after filtering with the combo boxes. I know of the column(n) method (derived from the third combo). However if the user does any sort of manipulation in the first or second combo then the value in the text box doesn't change accordingly. Is there any other way to update...
4
4056
by: faiyeah | last post by:
Private Sub PubName_AfterUpdate() Dim sql As String sql = "select PubCode from Publisher where PubName = '" & PubName.Value & "';" Set rst = CurrentDb.OpenRecordset(sql) MsgBox sql If Not rst.BOF Then rst.MoveFirst End If
3
3645
by: sparks | last post by:
I have a combo box that when you go to the next combo box it is filtered based on the value in the previous one. so if combo box 1 has fred as its value then combo box 2 has 1 2 3 for values. this works fine the first time thru. but later if I change combo box 1 combo box 2 list is still displaying the list form the previous value in combo box 1.
1
3002
by: Rodney Frisard | last post by:
Can anyone help me get this working. table1 has 3 field, CustId, CustName, CustRate table2 has 7 fields TimeId, TimeCustId, TimeCustName, TimeDate, TimeStartTime, TimeEndTime, TimeCustRate, TimeRemaks Both forms work great by them selves. Problem -- When I enter table2 - TimeCustId, I want the 2 fields
28
3252
by: jverri01 | last post by:
First, I am relatively new to working with variables. Most of my experience has been with interface design. i am using ACCESS ver. 2003, running in Windows XP. Second, I spent an hour searching through articles and posts to make sure the information I am seeking is not already posted on the site. I am beating my head against the wall trying to figure out something that seems like it should be very simple. The trouble is I do not fully...
8
11979
by: jmartmem | last post by:
Greetings, I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. I have three combo boxes ("FY", "Qtr" and "Mth") that contain the values for a project's deadline: fiscal year, quarter and month, respectively. My goal is to build an AfterUpdate event procedure such that when a user changes a value for any of the three aforementioned...
4
2398
by: dougmeece | last post by:
Morning Everyone... I have a table that needs to be append to and also updated. All the fields in the table are populated with data from the text boxes and combo boxes on a form. The Date Submitted defaults to 1/1/00 if the cboSubmittedBox field is "No". Otherwise it is selected from a calendar. The Date Entered field defaults to the current date. There are 3 sets of criteria that need to be checked for the update or append to take place. ...
0
7920
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
8401
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
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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
3900
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...
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.