M
msam137
Another user provided me the command and I modified it I hope this
makes sense to the person who attempts to help me.
With the command below not sure if the if statement is correct but
what I need to do is take what ever the user types in the txtbox and
compares it to another column in a table that is not the control
source.
Private Sub txtBox_AfterUpdate()
If "cboBox = " & txtbox & "" = 0 Then
DoCmd.RunSQL "Insert into tbl1 (employee name) values (txtbox);"
End If
What I am trying to accomplish due to the fact that i was getting
error Not able to add txtbox because it has no matching record in
tbl1. Was to be able to take my txtBox and compare the information
inside and compare it to all available records available in the
cboBox, If record found no matching value then run a SQL statement and
insert the value from txtBox in to the table so when I go to save the
data it will get rid of that error message.
What I did was created a hidden cboBox that had a row source == Select
DISTINCTROW [tbl1].[EmployeeName] FROM tbl1.My reasoning behind this
was since this form has a control source = tbl2 and that is essential
to the other txtFields on the form I did not want to mess that up.
makes sense to the person who attempts to help me.
With the command below not sure if the if statement is correct but
what I need to do is take what ever the user types in the txtbox and
compares it to another column in a table that is not the control
source.
Private Sub txtBox_AfterUpdate()
If "cboBox = " & txtbox & "" = 0 Then
DoCmd.RunSQL "Insert into tbl1 (employee name) values (txtbox);"
End If
What I am trying to accomplish due to the fact that i was getting
error Not able to add txtbox because it has no matching record in
tbl1. Was to be able to take my txtBox and compare the information
inside and compare it to all available records available in the
cboBox, If record found no matching value then run a SQL statement and
insert the value from txtBox in to the table so when I go to save the
data it will get rid of that error message.
What I did was created a hidden cboBox that had a row source == Select
DISTINCTROW [tbl1].[EmployeeName] FROM tbl1.My reasoning behind this
was since this form has a control source = tbl2 and that is essential
to the other txtFields on the form I did not want to mess that up.