associates
IS-IT--Management
Hi,
I have two question. I have a form that allows user to add new data into database. The form also checks whether the data entered by user is valid meaning no existence in the database. My first question is how to make the cursor point back to the textbox where the invalid data is without going to the next textbox.
Here is my code:
Private Sub Creditor_Code_Exit(Cancel As Integer)
If DCount("[Creditor_Code]", "Creditors", "[Creditor_Code]='" & Me.Creditor_Code & "'") > 0 Then
MsgBox "Sorry, " & Me.Creditor_Code & " already exist. Try a different code."
Me.Undo
'Me.Creditor_Code.setfocus ' this doesn't work
'me.Creditor_Code.tabindex = 0 ' this doesn't work either
End If
End Sub
My second question is that is there an easy way to check if the Creditor_Code textbox value has changed or not. The reason is this if i click on the edit button to edit a creditor info, I'd be prompted with a dialog popup message that says sorry POP already exist. Try a different code. The Creditor_Code_Exit sub is invoked when it shouldn't be.
SOrry for making this too long. I hope i can explain it well.
Thank you in advance and look forward to hearing from you
I have two question. I have a form that allows user to add new data into database. The form also checks whether the data entered by user is valid meaning no existence in the database. My first question is how to make the cursor point back to the textbox where the invalid data is without going to the next textbox.
Here is my code:
Private Sub Creditor_Code_Exit(Cancel As Integer)
If DCount("[Creditor_Code]", "Creditors", "[Creditor_Code]='" & Me.Creditor_Code & "'") > 0 Then
MsgBox "Sorry, " & Me.Creditor_Code & " already exist. Try a different code."
Me.Undo
'Me.Creditor_Code.setfocus ' this doesn't work
'me.Creditor_Code.tabindex = 0 ' this doesn't work either
End If
End Sub
My second question is that is there an easy way to check if the Creditor_Code textbox value has changed or not. The reason is this if i click on the edit button to edit a creditor info, I'd be prompted with a dialog popup message that says sorry POP already exist. Try a different code. The Creditor_Code_Exit sub is invoked when it shouldn't be.
SOrry for making this too long. I hope i can explain it well.
Thank you in advance and look forward to hearing from you