473,413 Members | 1,795 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,413 software developers and data experts.

Problem Syncing 2 Combo Box, I can't determine why my after event code is not working

Hi,

I'm very new to Access and having great difficultly trying to sync 2 combo boxes. I have been using The MS Access help for this issue. I have one Combo box titled sboPackageNumber and and another titled sboPackageDescription. My Table the data is taken from is called Sheet1. The columns on the table are Package Number and Package Description.

My code is as follows:


Expand|Select|Wrap|Line Numbers
  1. Sub Me.sboPackageDescription.RowSource = "SELECT Package_Description FROM" & _
  2.    " Sheet1 WHERE Package_Number = " & Me.sboPackageNumber & _
  3.    " ORDER BY Package_Description"
  4. Me.sboPackageDescription = Me.sboPackageDescription.ItemData(0)
  5.  
  6. End Sub

I'm currently getting Compile error : Expected:identifier

Thanks in advance.
Jun 28 '19 #1

✓ answered by zmbd

Sub Me.sboPackageDescription.RowSource = "SELE (...)
is malformed!!!

At best your code should appear to be something like:
Expand|Select|Wrap|Line Numbers
  1. Sub yourProcedureNameHere() 
  2. '
  3. 'You should build your rowsource string first
  4.   Dim myRowSQL as String
  5.   myRowSQL = _
  6.     "SELECT Package_Description FROM" & _
  7.        " Sheet1 WHERE Package_Number = " & _
  8.        Me.sboPackageNumber & _
  9.        " ORDER BY Package_Description"
  10. 'that way you can insert the following, <Ctrl><g> and see the result to check for proper form.
  11. '  Debug.Print myRowSQL
  12. '
  13.   Me.sboPackageDescription.RowSource = myRowSQL
  14. '
  15.   Me.sboPackageDescription.ItemData(0)
  16. '
  17. End Sub 
Take a read thru this insights article... I think this may be along the train of thought you're following:
Bytes > Sitemap > Microsoft Access / VBA Insights>Cascading Combo/List Boxes

I'll also send you a boilerplate with, imho, some better resources for things Access/VBA :) Bytes.com>InBox

2 901
zmbd
5,501 Expert Mod 4TB
Sub Me.sboPackageDescription.RowSource = "SELE (...)
is malformed!!!

At best your code should appear to be something like:
Expand|Select|Wrap|Line Numbers
  1. Sub yourProcedureNameHere() 
  2. '
  3. 'You should build your rowsource string first
  4.   Dim myRowSQL as String
  5.   myRowSQL = _
  6.     "SELECT Package_Description FROM" & _
  7.        " Sheet1 WHERE Package_Number = " & _
  8.        Me.sboPackageNumber & _
  9.        " ORDER BY Package_Description"
  10. 'that way you can insert the following, <Ctrl><g> and see the result to check for proper form.
  11. '  Debug.Print myRowSQL
  12. '
  13.   Me.sboPackageDescription.RowSource = myRowSQL
  14. '
  15.   Me.sboPackageDescription.ItemData(0)
  16. '
  17. End Sub 
Take a read thru this insights article... I think this may be along the train of thought you're following:
Bytes > Sitemap > Microsoft Access / VBA Insights>Cascading Combo/List Boxes

I'll also send you a boilerplate with, imho, some better resources for things Access/VBA :) Bytes.com>InBox
Jun 28 '19 #2
Thanks very much for your help and for taking the time to reply!
Jun 28 '19 #3

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

Similar topics

9
by: Larry Woods | last post by:
I have a site that works fine for days, then suddenly, I start getting ASP 0115 errors with an indication that session variables IN SEPARATE SESSIONS have disappeared! First, for background...
2
by: (Pete Cresswell) | last post by:
I've been perusing a "real-life" application and notice that for instance, in a button's Click() event, they don't write the processing code. Instead, they raise an event like AddNewRecord and...
5
by: will eichert | last post by:
Greetings. I have a problem with a combo box incorrectly displaying blank items when returning to a form from a modal form. It's fine when the main form first comes up, but gets messed up when the...
0
by: Bruce Dodds | last post by:
In an Access 2003 application, the selected value in a combo box disappears after the afterupdate event of the combo box applies a filter to the form. The combo box is unbound (Control Source is...
5
by: TS | last post by:
Is there a way in debug mode to determine what event caused the postback to occur without having an event handler for that event? thanks
9
by: AG | last post by:
Using VS 2005. Usually I work in VB.NET. In code behind when I need to add code to an event, I just select the object in the upper left dropdown of the code window and then the desired event in...
13
by: mirandacascade | last post by:
I want to set things up such that a section of code will have been executed by the time one clicks on the drop down arrow on a combo box control. Currently, that section of code resides in the...
4
by: lulu123 | last post by:
here's my problem 1) rowsource .RowSource = "select distinct , " & "from Projects " & " where =" & Me! I have the above code, and it works fine. however, i want to make the combo box in...
9
by: dozingquinn | last post by:
Hello, I have a combo box on a form that I would like to 'lock' the selection of after the user makes a selection, then either moves to the next record or saves the form. This selection will...
1
by: janakrai | last post by:
how to auto expand drop down combo box in onfocus event like click event
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
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
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...
0
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...

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.