Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
| Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old January 18th, 2008, 02:22 PM
Registered User
 
Join Date: Jan 2008
Location: Spanaway, WA, USA.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Goobz Send a message via AIM to Goobz Send a message via MSN to Goobz Send a message via Yahoo to Goobz
Default Trying to Utilize Bound Combo Boxes with no luck!

Okay all.. Here's my deal... I have tried and tried and tried to get these to work... I'm going to post what I have done, and what I am trying to do, and see if someone can help me figure crap out...

tblBuilding - PK is BuildingIDNum - Autonumber
tblBuildingZones - FK is BuildingIDNum via
Code:
SELECT DISTINCTROW Building.BuildingIDNum, Building.Name FROM Building ORDER BY Building.BuildingIDNum;
  cboBuilding - This has Building 1, Building 2, etc. The field displaying this info is "Name" in tblBuilding.

  cboBuildingZones - This has different "zones" for Building 1, Building 2, etc., that depending on which building is chose in cboBuilding, this will populate with the "zone" - First Floor, Second Floor, Mezzanine, etc. The field displaying this info is "InBuildingLocation" in tblBuildingZones. However, the field I need to write in the underlying form table is "DN.911Zone".

I wrote the following code in AfterUpdate of the Building ID, and I'm getting a highlighted yellow on "End Sub" as soon as I try and populate my cboBuildingZones box.

Code:
Private Sub cboBuilding_AfterUpdate()
    With Me![cboZoneID]
    If IsNull(Me!cboBuilding) Then
      .RowSource = ""
    Else
      .RowSource = "SELECT [InBuildingLocation] " & _
                   "FROM tblBuildingZones " & _
                   "WHERE [BuildingIDNum]=" & Me!cboBuilding
    End If
    Call .Requery
  End With
End Sub
I hope someone can help me out either by fixing my code, or taking the 2 minutes to write what probably should be a really stupid quick entry that I just can't get my hands around!

Thanx in advance!

  #2 (permalink)  
Old January 30th, 2008, 11:28 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I normally do cascading combo boxes like this on the On Change event of the first combo box:

Dim iPrimaryKey As Integer
Dim sSQL As String

iPrimaryKey = Me.Combo0
sSQL = "SELECT PKID, Name FROM tblCustomer WHERE [PKID] = " & iPrimaryKey

Me.Combo2.RowSource = sSQL
Me.Combo2.Requery

Does that help?

mmcdonal

Look it up at: http://wrox.books24x7.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combo Box Show all bound columns Coby Excel VBA 2 October 22nd, 2007 02:24 PM
Data type mismatch -- Combo box bound to database jamenijamjam Beginning VB 6 2 September 1st, 2006 08:36 PM
Combo Boxes nbuckwheat Access 1 January 15th, 2006 09:26 AM
Combo boxes socoolbrewster Access 1 March 4th, 2004 09:28 AM
combo boxes damnnono_86 Access 2 October 15th, 2003 09:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.