A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Synchronised combo boxes



 
 
Thread Tools Display Modes
  #1  
Old December 12th, 2005, 04:00 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Synchronised combo boxes

I have two combo boxes, WorkType and WorkNat in a subform where WorkNat
contents are dependent on WorkType. The following code works fine when I load
and test the subform on its own, but when I load the form in which the
subform is embedded I get a message "Enter Parameter Value" for Forms!Cases
Subform!WorkType, both when I load the form and when I select a new value for
the WorkType combo box. Also the WorkNat combo box dropdown list is blank.
Why is this happening?

Private Sub WorkNat_AfterUpdate()
Dim strSQL As String
strSQL = "Select WorkNature"
strSQL = strSQL & " from [Work Nature] Where WorkTRef = [Forms]![Cases
Subform]![WorkType];"
End Sub

Private Sub WorkType_AfterUpdate()
Me!WorkNat.Requery
End Sub

  #2  
Old December 12th, 2005, 04:16 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Synchronised combo boxes

Subforms are not part of the Forms collection. But Access should be able to
find the reference on the immediate form anyway.

If WorkTRef is a Number type field, try:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = " & Nz([WorkType],0)
& ";"

If it is a Text type:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = """ & [WorkType] &
""";"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Banterista" wrote in message
...
I have two combo boxes, WorkType and WorkNat in a subform where WorkNat
contents are dependent on WorkType. The following code works fine when I
load
and test the subform on its own, but when I load the form in which the
subform is embedded I get a message "Enter Parameter Value" for
Forms!Cases
Subform!WorkType, both when I load the form and when I select a new value
for
the WorkType combo box. Also the WorkNat combo box dropdown list is blank.
Why is this happening?

Private Sub WorkNat_AfterUpdate()
Dim strSQL As String
strSQL = "Select WorkNature"
strSQL = strSQL & " from [Work Nature] Where WorkTRef = [Forms]![Cases
Subform]![WorkType];"
End Sub

Private Sub WorkType_AfterUpdate()
Me!WorkNat.Requery
End Sub



  #3  
Old December 12th, 2005, 04:35 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Synchronised combo boxes

I'm sorry but I get the same result with your code!

"Allen Browne" wrote:

Subforms are not part of the Forms collection. But Access should be able to
find the reference on the immediate form anyway.

If WorkTRef is a Number type field, try:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = " & Nz([WorkType],0)
& ";"

If it is a Text type:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = """ & [WorkType] &
""";"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Banterista" wrote in message
...
I have two combo boxes, WorkType and WorkNat in a subform where WorkNat
contents are dependent on WorkType. The following code works fine when I
load
and test the subform on its own, but when I load the form in which the
subform is embedded I get a message "Enter Parameter Value" for
Forms!Cases
Subform!WorkType, both when I load the form and when I select a new value
for
the WorkType combo box. Also the WorkNat combo box dropdown list is blank.
Why is this happening?

Private Sub WorkNat_AfterUpdate()
Dim strSQL As String
strSQL = "Select WorkNature"
strSQL = strSQL & " from [Work Nature] Where WorkTRef = [Forms]![Cases
Subform]![WorkType];"
End Sub

Private Sub WorkType_AfterUpdate()
Me!WorkNat.Requery
End Sub




  #4  
Old December 12th, 2005, 04:52 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Synchronised combo boxes

Add the line:
Debug.Print strSQL

After it fails (asking for the parameter), open the Immediate Window
(Ctrl+G).
Copy the SQL statement.
Create a new query.
Switch it to SQL View (View menu.)
Paste in the SQL statment.
Switch to design view.
See if you can determine what's wrong with the SQL string.

I am assuming here that the code does something more than merely assigning
this to ths strSQL string, i.e. that it actully sets the RowSource of the
combo at some point.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Banterista" wrote in message
...
I'm sorry but I get the same result with your code!

"Allen Browne" wrote:

Subforms are not part of the Forms collection. But Access should be able
to
find the reference on the immediate form anyway.

If WorkTRef is a Number type field, try:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = " &
Nz([WorkType],0)
& ";"

If it is a Text type:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = """ & [WorkType]
&
""";"

"Banterista" wrote in message
...
I have two combo boxes, WorkType and WorkNat in a subform where WorkNat
contents are dependent on WorkType. The following code works fine when
I
load
and test the subform on its own, but when I load the form in which the
subform is embedded I get a message "Enter Parameter Value" for
Forms!Cases
Subform!WorkType, both when I load the form and when I select a new
value
for
the WorkType combo box. Also the WorkNat combo box dropdown list is
blank.
Why is this happening?

Private Sub WorkNat_AfterUpdate()
Dim strSQL As String
strSQL = "Select WorkNature"
strSQL = strSQL & " from [Work Nature] Where WorkTRef =
[Forms]![Cases
Subform]![WorkType];"
End Sub

Private Sub WorkType_AfterUpdate()
Me!WorkNat.Requery
End Sub



  #5  
Old December 12th, 2005, 07:22 PM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default Synchronised combo boxes

Yes it does set the RowSource as you suggest. I've found the problem which is
that you have to fully define the combo control on the subform as a subform
control. That was why it worked as a standalone form but not as a subform.
Thanks for your help as you pointed me in the right direction.

"Allen Browne" wrote:

Add the line:
Debug.Print strSQL

After it fails (asking for the parameter), open the Immediate Window
(Ctrl+G).
Copy the SQL statement.
Create a new query.
Switch it to SQL View (View menu.)
Paste in the SQL statment.
Switch to design view.
See if you can determine what's wrong with the SQL string.

I am assuming here that the code does something more than merely assigning
this to ths strSQL string, i.e. that it actully sets the RowSource of the
combo at some point.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Banterista" wrote in message
...
I'm sorry but I get the same result with your code!

"Allen Browne" wrote:

Subforms are not part of the Forms collection. But Access should be able
to
find the reference on the immediate form anyway.

If WorkTRef is a Number type field, try:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = " &
Nz([WorkType],0)
& ";"

If it is a Text type:
strSQL = strSQL & " from [Work Nature] Where WorkTRef = """ & [WorkType]
&
""";"

"Banterista" wrote in message
...
I have two combo boxes, WorkType and WorkNat in a subform where WorkNat
contents are dependent on WorkType. The following code works fine when
I
load
and test the subform on its own, but when I load the form in which the
subform is embedded I get a message "Enter Parameter Value" for
Forms!Cases
Subform!WorkType, both when I load the form and when I select a new
value
for
the WorkType combo box. Also the WorkNat combo box dropdown list is
blank.
Why is this happening?

Private Sub WorkNat_AfterUpdate()
Dim strSQL As String
strSQL = "Select WorkNature"
strSQL = strSQL & " from [Work Nature] Where WorkTRef =
[Forms]![Cases
Subform]![WorkType];"
End Sub

Private Sub WorkType_AfterUpdate()
Me!WorkNat.Requery
End Sub




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make combo boxes change contents depending on other combo boxes Glynn Using Forms 1 December 9th, 2005 01:32 PM
Help with basing Combo Boxes on other Combo Boxes Walt Using Forms 1 May 26th, 2005 03:01 AM
Confused about 3 combo boxes esparzaone New Users 1 April 28th, 2005 01:06 PM
Combo Boxes #1 Tom Using Forms 0 June 9th, 2004 03:50 AM
Multiple combo boxes Lee Worksheet Functions 2 May 6th, 2004 02:49 PM


All times are GMT +1. The time now is 02:36 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.