chrisjames25
Registered User.
- Local time
- Today, 15:43
- Joined
- Dec 1, 2014
- Messages
- 404
HI. Been a while but as snow has ground company to a halt i have some time to crack on with access.
I have a form with 2 comboboxes. THe second is populated depending on the choice of the first combobox.
What i wanted and what is kind of working is the following. I wanted that if i chose say Coke in cbo1, cbo2 would populate with all the varieties of coke sold. ie diet coke normal coke etc. However if i chose a brand with only 1 variety. Lets say Doctor Pepper, it would automatically lock the second cbo and populate it with the only variety available.
THis all works fine based on code below. NOTE - only put the code in that does the populating second cbo if only 1 exsits as it appears where error is
Heres issue. If i choose Dr Pepper in cbo1 the above code works and cbo 2 is automatically generated and locked. Brilliant for what i want.
THe problem is if i choose coke in cbo 1 then tab through all the form back to the top and change my cbo1 selection to doctor pepper the automatically chooseing of cbo2 and locking of it doesnt occur even if the vba code cycles past the code.
Any ideas? Is after update the incorrect event to use?
I have a form with 2 comboboxes. THe second is populated depending on the choice of the first combobox.
What i wanted and what is kind of working is the following. I wanted that if i chose say Coke in cbo1, cbo2 would populate with all the varieties of coke sold. ie diet coke normal coke etc. However if i chose a brand with only 1 variety. Lets say Doctor Pepper, it would automatically lock the second cbo and populate it with the only variety available.
THis all works fine based on code below. NOTE - only put the code in that does the populating second cbo if only 1 exsits as it appears where error is
Code:
Dim msg, style, title, response, MyString, Field, source, criteria
Field = StrTier1 & "_ID"
source = "Tbl_" & StrTier2
criteria = Field & "= " & Me.Cbo_Tier1
If DCount(Field, source, criteria) = 1 Then
Me.Cbo_Tier2.Requery
Me.Cbo_Tier2 = Me.Cbo_Tier2.ItemData(0)
Me.Cbo_Tier2.Locked = True
'Me.Cbo_Tier2.Enabled = False
With Me.Txt_NewTier3
.Value = ""
.Enabled = True
End With
With Me.Txt_ConfirmTier3
.Value = ""
.Enabled = False
End With
Me.SrchText.Value = vbNullString
Me.Child585.Requery
Heres issue. If i choose Dr Pepper in cbo1 the above code works and cbo 2 is automatically generated and locked. Brilliant for what i want.
THe problem is if i choose coke in cbo 1 then tab through all the form back to the top and change my cbo1 selection to doctor pepper the automatically chooseing of cbo2 and locking of it doesnt occur even if the vba code cycles past the code.
Any ideas? Is after update the incorrect event to use?