Will_J
09-03-2013, 06:02 AM
: pray2:
Hi All,
Thank you very much for all help and input in advanced, it's hugely appreciated!
I've been puzzling over this for FAR too long now, probably in the region of 6 hours; I'm a novice ... can you tell! : P Either way we all have to learn someway so here is my puzzle.
I am trying to write some code that gives another combo a record source based on the data selected in the first, there is some other criteria that has to be meet as well.
The code I have written is as follows;
Private Sub cmbTestRegion_AfterUpdate()
Dim strSource As String
strSource = "SELECT tblLocation.LocationName" & _
"FROM tblLocation " & _
"WHERE tblLocation.RegionID = '" & cmb.TestRegion & " '" & _
"AND tblLocation.InventoryAtLocation = 1" & _
"ORDER BY tblLocation.LocationName;"
Me.cmbTestLocation.RowSource = strSource
Me.cmbTestLocation.RowSource = vbNullString
End Sub
The English explanation is as follows;
The user will select a region from cmbTestRegion. When I select this region I want cmb.TestLocation to only show the regions based on the selection made in cmb.TestRegion and also and equal to 1 from the InventoryAtLocation Field in the Location Table (1 = Yes(I have a Yes / No combo in that field)).
Please help me! I'm going nuts and I know it's starring me in the face, in-fact it's jumping up and down going 'Your are stupid arn't you!!!' Haha.
Look forward to hearing from you all.
Best,
William
Hi All,
Thank you very much for all help and input in advanced, it's hugely appreciated!
I've been puzzling over this for FAR too long now, probably in the region of 6 hours; I'm a novice ... can you tell! : P Either way we all have to learn someway so here is my puzzle.
I am trying to write some code that gives another combo a record source based on the data selected in the first, there is some other criteria that has to be meet as well.
The code I have written is as follows;
Private Sub cmbTestRegion_AfterUpdate()
Dim strSource As String
strSource = "SELECT tblLocation.LocationName" & _
"FROM tblLocation " & _
"WHERE tblLocation.RegionID = '" & cmb.TestRegion & " '" & _
"AND tblLocation.InventoryAtLocation = 1" & _
"ORDER BY tblLocation.LocationName;"
Me.cmbTestLocation.RowSource = strSource
Me.cmbTestLocation.RowSource = vbNullString
End Sub
The English explanation is as follows;
The user will select a region from cmbTestRegion. When I select this region I want cmb.TestLocation to only show the regions based on the selection made in cmb.TestRegion and also and equal to 1 from the InventoryAtLocation Field in the Location Table (1 = Yes(I have a Yes / No combo in that field)).
Please help me! I'm going nuts and I know it's starring me in the face, in-fact it's jumping up and down going 'Your are stupid arn't you!!!' Haha.
Look forward to hearing from you all.
Best,
William