Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2006

Tip: Looking for answers? Try searching our database.

getting combo box to work in a subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Victor - 29 Sep 2006 03:38 GMT
Hi all,

I have been working on this code for many hours but I cant get it right.
Hope somebody could help a desperate here. This is my problem.

I have 3 combo boxes in subform. The second combo box row source will depend
on the selection of the first as well as the third will depend on the second.
All works fine when opened as a main form but when it is being called as
subform, I get this error message:

You can't assign a value to this object:
*The object may be a control on a read-form only.
*The object maybe on a form that is on design view.
*The value may be too large for this field

And when I click "OK", I get another error message:

Run-time error '2450'

And it said that it can't find the form (tbl_damagescount) I wrote in a
macro expression or visual basic code.

I have a table named: tbl_Defects (source of 3 combo boxes' row source)
I have a subform named: tbl_damagescount > this is a form, just a bad naming
:)
I have a main form: frm_Main

In the first combo box, I have this statement on "after update" event to
generate the row source for second combo:

strSQL = "SELECT DISTINCT tbl_Defects.Defects_Category FROM tbl_Defects" & "
WHERE tbl_Defects.Location = '" & Forms!tbl_damagescount.Damage_Location &
"'"

Defects_Category.RowSource = strSQL

In the second, I also have this statement to generate row source for the
third combo:

strSQL = "SELECT DISTINCT tbl_Defects.Defects FROM tbl_Defects" & " WHERE
tbl_Defects.Defects_Category = '" & Forms!tbl_damagescount.Defects_Category &
"'"

Defects.RowSource = strSQL

I know I'm missing something to include the main form in the statements
since it worked perfectly when opened alone.

For "You can't assign a value to this object:..." error, I don't know know
what triggered this.

I'm very new to this, looking forward for your replies.

This is the link of the database.

http://www.vpineda.com/PKGQADB.mdb

Thank you very much.

vic.
Marshall Barton - 29 Sep 2006 05:30 GMT
>I have been working on this code for many hours but I cant get it right.
>Hope somebody could help a desperate here. This is my problem.
[quoted text clipped - 29 lines]
>
>Defects_Category.RowSource = strSQL
[snip]

A subform does not exist in the Forms collection.  Your
reference to it in the strSQL= lines will fail.  Actually,
this is a good example of why you should use Me whenever
possible.

strSQL = "SELECT DISTINCT tbl_Defects.Defects_Category  " _
                & "FROM tbl_Defects  " _
                & "WHERE tbl_Defects.Location = '" _
                        & Me.Damage_Location & "'"

Signature

Marsh
MVP [MS Access]

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.