Error while assigning a value to text box

murthyspd

Registered User.
Local time
Today, 17:21
Joined
Aug 3, 2006
Messages
31
Hi

I am assigning a value from a table to text box on the form through VBA. It gives the following error :

Run time error 2115

The macro or function set to the BeforeUpdate or ValidationRule property for this field is preventing MS Access from saving the data in the field. I have no BeforeUpdate or Validation event for the text box. What else could be the cause ? Please assist.
 
How are you assigning the value to the TextBox? Is it a bound control?
 
Hi
The text box is unbound.
 
What VBA are you using to assign the value to the control?
 
Is there a reason you are not using a bound control?
 
I am using ADODB for assigining. There is no particular reason for not using bound control. Just wanted to use ADODB.
 
Can you post your ADO code? I'm not particularly up on it but I'll give it a shot.
 
Here is the code. cmbOP is a combo box from where an employee is chosen.

Private Sub cmbOP_click()
Set rsGetTarget = New ADODB.Recordset
If cmbOP.Text <> "" Then
' rs.Open "SELECT * FROM tblEmployeeDetails WHERE Name='" & cmbOP.Text & "'", con, adOpenKeyset, adLockPessimistic

rs.MoveFirst
rs.Find "Name='" & cmbOP.Text & "'"

' rsGetTarget.Open "SELECT * FROM tblTargets where badge_no='" & rs!badge_no & "' AND set_date = #" & lblToday_Date.Caption & "#", con, adOpenKeyset, adLockPessimistic
rsGetTarget.Open "SELECT * FROM tblTargets where badge_no='" & rs!badge_no & "'", con, adOpenKeyset, adLockPessimistic
With rsGetTarget
If .RecordCount > 0 Then
txtGB.SetFocus

txtGB.Text = !GB
txtRest_of_Online.SetFocus
txtRest_of_Online.Text = !Rest_of_Online
txtEDHC_OGID.SetFocus
txtEDHC_OGID.Text = !EDHC_OGID
txtEDHC_PO_Exception.SetFocus
txtEDHC_PO_Exception.Text = !EDHC_PO_Exception
txtEDHC_B2B.SetFocus
txtEDHC_B2B.Text = !EDHC_B2B
txtARB_OGID.SetFocus
txtARB_OGID.Text = !ARB_OGID
txtARB_IPORT.SetFocus
txtARB_IPORT.Text = !ARB_IPORT
TXTARB_DOMS.SetFocus
TXTARB_DOMS.Text = !ARB_DOMS
txtOP_QC.SetFocus
txtOP_QC.Text = !OP_QC

Else
txtGB.SetFocus
txtGB.Text = ""
txtRest_of_Online.SetFocus
txtRest_of_Online.Text = ""
txtEDHC_OGID.SetFocus
txtEDHC_OGID.Text = ""
txtEDHC_PO_Exception.SetFocus
txtEDHC_PO_Exception.Text = ""
txtEDHC_B2B.SetFocus
txtEDHC_B2B.Text = ""
txtARB_OGID.SetFocus
txtARB_OGID.Text = ""
txtARB_IPORT.SetFocus
txtARB_IPORT.Text = ""
TXTARB_DOMS.SetFocus
TXTARB_DOMS.Text = ""
txtOP_QC.SetFocus
txtOP_QC.Text = ""
End If
End With

End If
 
Wow Murphy,
An awful lot of work when Access will do all of that for you with very little code when the form is bound and all of the controls are bound. Are you aware that if you use the .Value property of a control (the default property) that it is not necessary for the control to have the focus? Why are you using the Click() event rather than the AfterUpdate event of the ComboBox?
 

Users who are viewing this thread

Back
Top Bottom