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

Whats wrong with my Cascading Combo Code

Hi all

I am a newbie when it comes to access. My company requires that all Databases run on the company SQL back-end as a result i have a Access project that connects to the server.

I have two tables, table 1 called tblProjectDetails, table 2 called tblLearners
The fields in tblProjectDetails are
Expand|Select|Wrap|Line Numbers
  1. ProjectPK numeric (Its also the Primary Key)] 
  2. Name char (50) 
  3. Description char (50) There are other field but they dont play a role in the comboboxes
  4.  
  5. The fields in tblLearners are 
  6. LeanerPk numeric (Primary Key) 
  7. Surname char (50)
  8. FirstName char (50)
  9. ProjectNo numeric
I have created two bound combo boxes and the idea is that one of my staff members can select the project first(called cboProject), once that is done then the second combo box would show the appropriate learners(called cboLearner).

I have the following code as an after update event for cboProject

Expand|Select|Wrap|Line Numbers
  1.  cboLearner.RowSource = "SELECT * from tblLearners WHERE ProjectNo = " & [Forms]![frmProjectMangerTracking]![subfrmlinkin]![cboProject] 
frmProjectMangerTracking - is the main form that i am using
subfrmlinkin - is the subform that i am using. the name is temporary until i solve my problem

When i execute the cascading combo box cboLearner is blank. Can somebody please show where i am going wrong?

Thanks in advance
Aug 21 '08 #1
12 1687
Stewart Ross
2,545 Expert Mod 2GB
Hi. It would appear that you are referring to a control on a subform as part of your WHERE clause. The syntax for this is slightly different to what you have written, as the subform is treated as a control when it is on the main form. To access a control within the subform you need to refer to its form property:

Expand|Select|Wrap|Line Numbers
  1. WHERE ProjectNo = " & [Forms]![frmProjectMangerTracking]![subfrmlinkin].Form![cboProject] 
See the following HowTo article on Referring to Items on a Subform for further examples.

-Stewart
Aug 21 '08 #2
FishVal
2,653 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1.  cboLearner.RowSource = "SELECT * from tblLearners WHERE ProjectNo = " & [Forms]![frmProjectMangerTracking]![subfrmlinkin]![cboProject] 
Hello, there.

I almost sure Access project gets Recordset to fill combobox passing SQL expression directly to SQL server. If so, then, I guess, you couldn't include any VBA and/or any object's property/method calling in the SQL expression.

Regards,
Fish
Aug 22 '08 #3
Thanks guys

It seems now I'm still stuck 'cos i either get a blank combo box or an error message which reads
The record source 'SELECT * from tblLearners where ProjectNo = 39' specified on this form or report does not exist
Any ideas?

Thanks again
Aug 22 '08 #4
Stewart Ross
2,545 Expert Mod 2GB
Hi. Well, this is an advance - the SQL quoted in your error message is at least showing that the project number is being passed correctly from the subform control as part of the row source statement. One error resolved.

As a temporary measure to make sure the combo can actually access tblLearners, set the row source of the combo in design view to tblLearners then switch to form view and see if the combo shows the rows from the table when selected (the fields displayed will depend on how many columns you have set the combo to show). If it can, try replacing the row source manually with the SQL statement but without its WHERE clause, again to see that the combo can access the table's rows but this time via the SQL statement. As a last check, add back the WHERE clause to the rowsource manually and see if that works. In each case you are narrowing the potential causes of the error.

Let us know how you get on.

-Stewart
Aug 22 '08 #5
Hi Guys

I really do appreciate the help. at least i have found where the problem is, but my knowledge is a bit limited so i'm not sure what the next step is to resolve it.

Stewart i followed your steps ans as soon as i added the WHERE clause it all fell apart and the combo box was blank again

Thanks
Aug 22 '08 #6
FishVal
2,653 Expert 2GB
Could you please post your code as it looks right now?

P.S. G..d save us. Add please semicolon to the end of SQL statement. I had a situation in the past when only absense of that semicolon prevented SQL server to execute command correctly.
Aug 22 '08 #7
Stewart Ross
2,545 Expert Mod 2GB
OK, so now check that you really have a value of 39 in the projectno field of tblLearners - as we know that the table itself is accessible, and that the WHERE clause is not matching the records.

Please also check carefully when you open the table whether the projectno field is displayed left-aligned or right-aligned. If it is left-aligned it is not a number but a string value - and the where clause needed to filter your records would be slightly different if it is, as you would need to include single quotes before and after the value you are comparing.

-Stewart
Aug 22 '08 #8
Thanks Guys i solved it.... but i certainly would not have got there with out your help
Aug 22 '08 #9
Stewart Ross
2,545 Expert Mod 2GB
Well done for solving this; as a matter of interest, what was it that was wrong?

-Stewart
Aug 22 '08 #10
Well done for solving this; as a matter of interest, what was it that was wrong?

-Stewart
I'm not totally sure but as i rebult the statement from the Where clause it worked. There must have been an error there

I have distributed the project to my staff and when they try to access the form on cboLearner they get the following error message

Expand|Select|Wrap|Line Numbers
  1.  SELECT permission denied on 'tblLearners',  database 'assessment informationtracking', owner 'dbo' 
i have checked the permissions on the server and the users have the following permissions on the table
SELECT
INSERT
UPDATE

any ideas?
Aug 26 '08 #11
Stewart Ross
2,545 Expert Mod 2GB
Hi. Unfortunately, I have no experience in this area (permissions in SQL server). We have a SQL Server forum which may be able to help you better than I can.

A quick Google search on SELECT PERMISSION DENIED shows many hits on this topic - too many to list here, but an interesting thread from MSDN which provides some insight into the issues is linked here. The permission problems could apparently have been resolved by dropping and rebuilding the database in this case, but the poster concerned actually did an over-the-top reinstall of everything. I hope you don't end up taking such an approach to resolve your issues!

-Stewart
Aug 26 '08 #12
Hi

Thanks for the advice

The solution was a simple one and when you look at a problem for too long you sometimes don't see the wood for the trees.

All my users are in two different groups. The one had permissions to the table and the other had deny access to the table, the net result is that there global permission status was deny and as a result they were not allowed access to the table.

I am glad to say that it was simple and no drastic measures had to be taken
Aug 26 '08 #13

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

Similar topics

0
by: cognoscento | last post by:
I'm currently putting together a database for my work (not an expert by any stretch, so muddling through as best as I can... you know the story...) and I could use some advice and hand-holding ...
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
4
klarae99
by: klarae99 | last post by:
Hello, I am working on an Access 2003 Database. The tables that pertain to this issue are tblOrg, tblState, tblCity, and tblZip. I have posted the table structure with only the pertinant fields...
1
kcdoell
by: kcdoell | last post by:
Good Morning: I have a form where I am trying to create cascading combo boxes. I have done this before but I am getting the following error that is throwing me off: Procedure declaration...
3
kcdoell
by: kcdoell | last post by:
I have 5 cascading combo boxes on a form. Below is a sample of my vb in the first combo box: Private Sub CboDivision_AfterUpdate() 'When the Division is selected, the appropriate Segment...
7
by: Toireasa | last post by:
Hi, Newbie Access developer here, and my first post on this forum, so I might not get everything right - thanks in advance for your help and your patience! I'm using Access 2007, in XP. I'm...
1
by: bluclouds9 | last post by:
I am new to Access and have been charged with creating a database for our course alumni. I currently have a "Contacts" form and am trying to create a subform to hold the course alumni...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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
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...

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.