This fails with a "variable not defined" error.Code:Private Sub cboCategories_2_AfterUpdate() Me!BuildingID = cbocatagories_2.Column(1) Me!Building = cbocatagories_2.Column(2) End Sub
I'm asking it to write the values in two columns of a selection in a combo box. I'm not even sure if the above code should work as I pilfered it from another website! ha
Edit - The "cbocatagories_2" is what is highlighted with the error.
Last edited by CHR1S; 7th March 2013 at 03:35 PM.
CHR1S (7th March 2013)
I may have to add "I hate Access" back to my sig!
Data type mismatch in criteriaThe cascading combos work, just not the data entry. ConfusedCode:Private Sub cboProducts_2_AfterUpdate() Me!BuildingID = cboCategories_2.Column(1) Me!Building = cboCategories_2.Column(2) Me!Assets.Building.SetFocus Me!Assets.Building.Dropdown Me!RoomID = cboProducts_2.Column(2) Me!Room = cboProducts_2.Column(1) End Sub
Last edited by CHR1S; 8th March 2013 at 02:04 PM.
My thinking is you're trying to pass a Column object as opposed to the value held in the column...Code:Me!BuildingID = cboCategories_2.Column(1).Value
EDIT: Just checked some of my own code and that .Value is not necessary. So next step is, are you trying to pass a string to a column that only accepts integers? You can convert the string to an int with CInt, like so:
Code:Me!BuildingID = CInt(cboCategories_2.Column(1))
Last edited by LosOjos; 8th March 2013 at 02:26 PM.
Ive removed all the code, still get the error. Weird!
Bound columns are correct and database is expecting a string and getting a string.
Last edited by CHR1S; 8th March 2013 at 02:38 PM.
Just wiped the record im using for testing and the error has gone.
Not sure what was in it that it didnt like as its a combo box selection thats not changed.
Back to the issue at hand -
The BuildingID and RoomID are filled correctly as they are the bound and the control source.Code:Private Sub cboProducts_2_AfterUpdate() Me.Assets.Building = Me.cbocatagories_2.Column(1) Me.Assets.Building.SetFocus Me.Assets.Building.Dropdown Me.Assets.Room = Me!cboProducts_2.Column(2) End Sub
Room and Building (their text names) are not filled in at all.
What are you actually trying to do, populate entries in the database based on selections made in combo boxes?
If so, it might be easier to cut out the middle man and write straight to the DB.
There are currently 1 users browsing this thread. (0 members and 1 guests)