Updating a record with Value from a combo box

  • Thread starter Thread starter Bobbak
  • Start date Start date
B

Bobbak

Hello All,
I am have created this form that allows the user to Add/Edit an
Employees info. In it I have several Combo Boxes that forces the user
to select one of the options containned in the combo box, the only
problem is when I click on the button to save the changes it doesn't
write the selected value to the record. Instead I get an error that
says "Object Required". Now I place a condition in my code so that if
the value in the combo box is blank to not update that record field.

Here is a sample of the code that I am using.

If Me.ComboLanguage Is Not Null Then
[LANGUAGE] = Me.ComboLanguage
End If

I'm pretty sure it's wrong but I am not clear as to how to do this
correct seing my knowledge of VB is very basic.
Thanks in advance for your help.
 
Bobbak said:
Hello All,
I am have created this form that allows the user to Add/Edit an
Employees info. In it I have several Combo Boxes that forces the user
to select one of the options containned in the combo box, the only
problem is when I click on the button to save the changes it doesn't
write the selected value to the record. Instead I get an error that
says "Object Required". Now I place a condition in my code so that if
the value in the combo box is blank to not update that record field.

Here is a sample of the code that I am using.

If Me.ComboLanguage Is Not Null Then
[LANGUAGE] = Me.ComboLanguage
End If

I'm pretty sure it's wrong but I am not clear as to how to do this
correct seing my knowledge of VB is very basic.
Thanks in advance for your help.

I believe the error is in how you are referring to the fields. You are
supposed to use "!" as a separator instead of ".". For instance, your code
should be:

If Me!ComboLanguage Is Not Null Then
[LANGUAGE] = Me!ComboLanguage
End If

Steve
 
Bobbak said:
Hello All,
I am have created this form that allows the user to Add/Edit an
Employees info. In it I have several Combo Boxes that forces the user
to select one of the options containned in the combo box, the only
problem is when I click on the button to save the changes it doesn't
write the selected value to the record. Instead I get an error that
says "Object Required". Now I place a condition in my code so that if
the value in the combo box is blank to not update that record field.

Here is a sample of the code that I am using.

If Me.ComboLanguage Is Not Null Then
[LANGUAGE] = Me.ComboLanguage
End If

I'm pretty sure it's wrong but I am not clear as to how to do this
correct seing my knowledge of VB is very basic.

"Is Not Null" is a SQL statement, not one recognized in VBA.

Use the VBA IsNull() function instead.

If IsNull(Me.ComboLanguage) = False Then
[LANGUAGE] = Me.ComboLanguage
End If
 
Back
Top