473,403 Members | 2,270 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,403 software developers and data experts.

Problem with reference to another form control

49
The form I am working on at the moment is designed to allow a data entry person to add new questions for the assessment of some properties. I am trying to set up cascading combo boxes that force the user to specify a category of assessment ("Management" or "Building"), and then choose a section/question type from within the relevant category, before they can save a new record.

However, when the form loads, I receive the error "Enter Parameter Value: Me!cboMgtBldg".

The row source for cboAssessmentSection is the following query:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblAssessmentTypes.AssessmentTypeIndex, tblAssessmentTypes.AssessmentTypeName
  2. FROM tblAssessmentTypes
  3. WHERE (((tblAssessmentTypes.AssessmentMgtBldgIndex)=[Me]![cboMgtBldg]))
  4. ORDER BY tblAssessmentTypes.AssessmentTypeOrder;
I've had the same problems in similar situations using this machine. Sort of an Access newbie... but all the posts I've seen on this sort of technique make it seem straightforward and easy, so either I've missed a critical step, or perhaps something is missing from the local copy of Access. Thanks for any help!

ETA: Sorry, I forgot--this is Access 2003, but the database window says "(Access 2000 file format)".
Feb 16 '10 #1

✓ answered by MikeTheBike

Hi

Yes, if you have typed the SQL into the CoboBox RowSource in design view then this is prctically the same as specifying a stored query in the RowSource, hence the need for explicit reference to the form.

To use th Me object you need to construct the SQL in code and then assign it to the row source, ie.
Expand|Select|Wrap|Line Numbers
  1. dim sql as strong
  2.  
  3. sql = "SELECT tblAssessmentTypes.AssessmentTypeIndex, "
  4. sql = sql & "tblAssessmentTypes.AssessmentTypeName  "
  5. sql = sql & "FROM tblAssessmentTypes  "
  6. sql = sql & "WHERE (((tblAssessmentTypes.AssessmentMgtBldgIndex)=" & Me.cboMgtBldg & "))  "
  7. sql = sql & "ORDER BY tblAssessmentTypes.AssessmentTypeOrder;"
  8.  
  9. Me.ComboBox.RowSource = sql
  10.  
  11. Me.ComboBox.Requry
You will need to assign the sql and requery each time cboMgtBldg is changed/updated.

(In fact you do not have to use the Me object as this is the default object and is automatically implied.)

HTH


MTB

4 2801
MikeTheBike
639 Expert 512MB
Hi

I assume that the combo data source is a stored query, and the query posted is copied from the query designer SQL view.

If that is the case you need to reference the form explicitly (ie. not with the 'Me' Object) ie.
Expand|Select|Wrap|Line Numbers
  1. SELECT tblAssessmentTypes.AssessmentTypeIndex, tblAssessmentTypes.AssessmentTypeName 
  2. FROM tblAssessmentTypes 
  3. WHERE (((tblAssessmentTypes.AssessmentMgtBldgIndex)=[Forms]![YourFormName]![cboMgtBldg])) 
  4. ORDER BY tblAssessmentTypes.AssessmentTypeOrder; 
(this assumes AssessmentMgtBldgIndex is numeric)

Note: If you construct the Combo Data Source in VB code then you would concatenate the criteria value into the string (when the Me object could be used - or implied - as desired).

HTH


MTB
Feb 16 '10 #2
JeremyI
49
Thanks, Mike. No, sorry to be unclear, but it is not a stored query; just the SQL statement stored in the Row Source property. AssessmentMgtBldgIndex is indeed numeric.

I've been playing around with this problem in the meantime, though, and the method of referring to the exact form name does seem to work, with the addition of code to requery the dependent combobox at appropriate times. If the exact form name is the best option, that won't be a problem here or in other simple spots. I guess I am really trying to figure out and practice how and when "Me!" can be used, because I think I'll need it for some of the more complicated forms in the database.

(For some reason, I also couldn't adapt the VBA from the Cascading Combo/List Boxes tutorial, which does use "Me!" programmatically. The error disappeared but so did the combobox options!)

Are there any circumstances in which it would work to use "Me!" in the rowsource SQL of a combobox on a form?
Feb 16 '10 #3
MikeTheBike
639 Expert 512MB
Hi

Yes, if you have typed the SQL into the CoboBox RowSource in design view then this is prctically the same as specifying a stored query in the RowSource, hence the need for explicit reference to the form.

To use th Me object you need to construct the SQL in code and then assign it to the row source, ie.
Expand|Select|Wrap|Line Numbers
  1. dim sql as strong
  2.  
  3. sql = "SELECT tblAssessmentTypes.AssessmentTypeIndex, "
  4. sql = sql & "tblAssessmentTypes.AssessmentTypeName  "
  5. sql = sql & "FROM tblAssessmentTypes  "
  6. sql = sql & "WHERE (((tblAssessmentTypes.AssessmentMgtBldgIndex)=" & Me.cboMgtBldg & "))  "
  7. sql = sql & "ORDER BY tblAssessmentTypes.AssessmentTypeOrder;"
  8.  
  9. Me.ComboBox.RowSource = sql
  10.  
  11. Me.ComboBox.Requry
You will need to assign the sql and requery each time cboMgtBldg is changed/updated.

(In fact you do not have to use the Me object as this is the default object and is automatically implied.)

HTH


MTB
Feb 17 '10 #4
JeremyI
49
Oh, right. Good stuff to know. Thanks very much, Mike!
Feb 17 '10 #5

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

Similar topics

2
by: Zippy | last post by:
Some months ago, we requested help from this newsgroup on how to replace the library reference of a database with another library reference, prior to creating an MDE. I got the following answer...
14
by: simonmarkjones | last post by:
Hi, I'm having a bit of trouble editing an old database that was created quite a while ago by someone else. There is a form that lets the user select a member of staff and show details about the...
3
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
8
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
13
by: Lee Newson | last post by:
Hi, I have just written my first application using VB.NET. The app works fine when i am running it within .NET for debugging purposes, however when i try to run the app from the .exe file that...
0
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file. One project that build a class library dll One project that build a windows control dll In...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
9
by: John Brown | last post by:
Hi there, Has anyone had any problems debugging a thread in VS 2005. If I put a breakpoint on a worker thread (the only one in the app) and then run the app two things happen: 1) It takes an...
12
by: Ron M. Newman | last post by:
Hi, I can load an assembly using the Assembly.Load(....) However, I'd like dynamic loading of assemblies to be identical to putting an assembly reference in your VS2005 project. and yes, I...
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
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
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
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
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...
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.