Adding the value of a combobox to a hidden column when a user enters a new record (1 Viewer)

RGoberto

New member
Local time
Today, 00:00
Joined
Aug 14, 2013
Messages
2
I'm very new to access so I'm not sure about the correct way to go about this. I have a table with a 'category' column, a form which hides the category column, and a combobox to filter the category, let's say R, C, and F.

What I want accomplish is to have the value of the comobox applied to the hidden 'category' column when a user enters a new record into the form.

Is there I way I can get an instance to the record as it's being entered and modify the data using VB? Or would I have to write a sort of pop() function and have it run afterInsert and then modify it that way? Can I even alter the table using VB like this?

Thank you
 

twcaddell

Registered User.
Local time
Today, 02:00
Joined
Apr 8, 2013
Messages
31
I assume you mean hidden field instead of column
One possible solution is to assign the value in the combo-box to a variable (ensures combo-box value doesn't change. Can be done using the syntax "variable = combobox.value"

Then you can insert the value using the variable into your record either using a record source or a sql statement. If the record exists, use the edit method for record source or an UPDATE statement for sql. If the record is new the use new method or an INSERT INTO statement for SQL.

Hope this is clear
TC
 

Mihail

Registered User.
Local time
Today, 10:00
Joined
Jan 22, 2011
Messages
2,373
...or to bound your combo directly to that field. No more code, SQL or other Mandarin's words :)

Welcome to the forum !
 

RGoberto

New member
Local time
Today, 00:00
Joined
Aug 14, 2013
Messages
2
...or to bound your combo directly to that field. No more code, SQL or other Mandarin's words :)

Welcome to the forum !


What I did was set the default value of the category field in properties to

=Left([Forms]![Formname]![Combo12],1)
[only need the first letter]
Which seems to have worked. Is this what you meant? If not, is there any documentation you could point me towards?
 

Mihail

Registered User.
Local time
Today, 10:00
Joined
Jan 22, 2011
Messages
2,373
What I want accomplish is to have the value of the comobox applied to the hidden 'category' column when a user enters a new record into the form.
My mistake. Sorry. I've misunderstand your request.

Use the Click event for your combo
In this event:
Me.HiddenControlName.DefaultValue = Left(Me.Combo12,1)
 

Users who are viewing this thread

Top Bottom