Microsoft Access Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft Access Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 28th, 2004, 01:14 PM
user522 user522 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 user522 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
combobox in subform dependent on main form value

Hi all,

I have a main form called mainform and there is subform1 in it. In subform1, there is subform2.

The following is an illustration:

Mainform - caseID (pk)
subform1 - scenarioID (pk) , caseID
subform2 - outcomeID (pk), scenarioID, requirementID (this is a combo box listing all the requirements for caseID from Mainform.)

The requirementID is from a requirement lookup table with the fields (requirementID, requirementText, caseID).
In subform2, I want the requirementID combo box to list only requirements that has the same caseID as on the mainform.

What I've done is on subform2, I created a combobox RequirementList and added the following code:

Code:
 
Private Sub RequirementList_GotFocus()
Dim strSQL As String
 
'Develop SQL statement for row source of Project Number combo box:
strSQL = "SELECT [tblRequirements].[rqmtid], [tblRequirements].[rqmt] " & _
			"FROM tblRequirements WHERE " & _
			"[tblRequirements].[usecaseid] = 45"
 
'Finish establishing combo box properties:
RequirementList.RowSource = strSQL
RequirementList.RowSourceType = "Table/Query"
RequirementList.BoundColumn = 1
 
End Sub


What's happening is this code works for 3 records and crashes access. What's wrong with this?
Should I place this at another event?

Any help is grateful.

Anthony

Reply With Quote
  #2  
Old December 29th, 2004, 10:27 AM
BetsyBean BetsyBean is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 14 BetsyBean User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 22 m 15 sec
Reputation Power: 0
Hi,

I may just confuse you, but it seems that if you have correct one to many relationships in your database and that the subforms are correctly linking on the primary to foreign keys, wouldn't the requirements (RequirementID, RequirementText) pop up for the CaseID and ScenarioID automatically? Is this an entry or edit form or both?

If you have a one to many relationship established for CaseID to ScenarioID, then a one to many relationship from ScenarioID to OutcomeID, I think it should work. The CaseID should not have to be saved with the RequirementID Lookup Table.

Now in your form creation, in subform 2, your default view should be continuous forms, so that multiple requirements can be entered or seen for the CaseID that is currently selected.

I hope I have helped some, BetsyBean

Reply With Quote
  #3  
Old December 29th, 2004, 11:41 AM
MrBullwinkle MrBullwinkle is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Wild and Wonderful, West Virginia
Posts: 27 MrBullwinkle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to MrBullwinkle Send a message via AIM to MrBullwinkle Send a message via MSN to MrBullwinkle Send a message via Yahoo to MrBullwinkle
Yes, if you set up the relationships, and the form and combobox recordsources correctly, you shouldn't need to do queries in code. Thats the nice thing about subforms.
Also since your code is not dynamic, you could just put each of those lines into the controls themselves.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft Access Development > combobox in subform dependent on main form value


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT