Set Focus but cannot edit form text control

jom1918

Registered User.
Local time
Tomorrow, 03:52
Joined
Apr 26, 2011
Messages
30
I have a form with 3 controls boudn to the following fields:

DPBatchNumber - textbox where the company batch details are recorded.
SupplierBatchNumber - textbox where the supplier's batch info is recorded
SupplierBatch - query control where either the DPBatchNumber or the SupplierBatchNumber is stored on the for for users.

The SupplierBatchNumber field is a required field.

I have the following code written. The first part works, but after the user enters data in the input box the cursor moves to the correct control, but I cannot edit the control (SupplierBatch). It is behaviing like it is locked, but it is not locked. Can someone tell me what I am doing wrong?
=================================================
Private Sub SupplierBatch_Exit(Cancel As Integer)
Dim strNewBatch As String
Dim stUserInput As String

If Nz([SupplierBatch]) = "" Then
stUserInput = InputBox("Supplier Batch Details MUST be entered to record this quarantine item. Please enter the Supplier Batch Details Now", "Supplier Batch Details")
Me.DPBatchNumber.SetFocus
Me.SupplierBatch.SetFocus
Me.SupplierBatch = stUserInput
Else
strNewBatch = Me.SupplierBatch.Value
Me.SupplierBatchNumber = strNewBatch
End If
Me.QReg = Me.QID
End Sub
 
Are the fields from the same or different tables? If the fields are from different tables that would explain why you cannot edit them. If you specifically need the interface to work as you have described it, you may have to make the controls "unbound" and then when ready, use code to write the data provide by the user to the appropriate field in the appropriate table.

If you are using a query as the Record Source of your form, try editing the fields in the query to see if you can edit them there. If not, then you will not be able to edit them in the form. If you can edit the fields in the query, then there is some other issue.
 
Hi Mr. B.,
I am an idiot. I realised what I was doing wrong. I had an expression in the query field that I forgot to take out when I wrote up the code.

Just having a very blode moment.!

Sorry.

But thanks for the reply. All is now working, just put the if statements that was in the query into the code and Voila!
 

Users who are viewing this thread

Back
Top Bottom