Setfocus or docmd.gotocontrol

G

Guest

Good morning
I'm struggling on an unbound form that checks for the prior entry of an Invoice. If the Invoice exists (for a given Purchase Order - I don't have the 2nd condition in yet since I'm troubleshooting this. I can put that in later), I have a msgbox and want the value to stay in the textbox, but for it to regain the focus. Here's what I have so far

Public Sub InvoiceNumber_Exit(Cancel As Integer
Dim invoicecount As Varian
invoicecount = DCount("[InvoiceNumber]", "T_Invoice", "InvoiceNumber = Forms!F_16!InvoiceNumber"
If invoicecount <> 0 The
MsgBox ("That Invoice already exists for PO#: " & Left(PONumber, 4) & "-" & Right(PONumber, 4) & Chr$(10) & " Please verify it and reenter"
DoCmd.GoToControl "InvoiceNumber
End I
End Su

Public Sub Payment_Enter(
Dim invoicecount As Varian
If invoicecount <> 0 Then InvoiceNumber.SetFocu
End Su

Can someone please help me out

Thank you in advance
Derek
 
F

fredg

Good morning,
I'm struggling on an unbound form that checks for the prior entry of an Invoice. If the Invoice exists (for a given Purchase Order - I don't have the 2nd condition in yet since I'm troubleshooting this. I can put that in later), I have a msgbox and want the value to stay in the textbox, but for it to regain the focus. Here's what I have so far:

Public Sub InvoiceNumber_Exit(Cancel As Integer)
Dim invoicecount As Variant
invoicecount = DCount("[InvoiceNumber]", "T_Invoice", "InvoiceNumber = Forms!F_16!InvoiceNumber")
If invoicecount <> 0 Then
MsgBox ("That Invoice already exists for PO#: " & Left(PONumber, 4) & "-" & Right(PONumber, 4) & Chr$(10) & " Please verify it and reenter")
DoCmd.GoToControl "InvoiceNumber"
End If
End Sub

Public Sub Payment_Enter()
Dim invoicecount As Variant
If invoicecount <> 0 Then InvoiceNumber.SetFocus
End Sub

Can someone please help me out?

Thank you in advance!
Derek

Cancel is an Argument in the Exit Sub procedure.

If invoicecount <> 0 Then
MsgBox ("That Invoice already exists for PO#: " & Left(PONumber,
4) & "-" & Right(PONumber, 4) & Chr$(10) & " Please
verify it and reenter")
Cancel = True
End If
 
G

Guest

Thanks, Fred! I appreciate the help
Dere

----- fredg wrote: ----

On Mon, 10 May 2004 09:16:02 -0700, Derek Wittman wrote
Good morning
I'm struggling on an unbound form that checks for the prior entry of an Invoice. If the Invoice exists (for a given Purchase Order - I don't have the 2nd condition in yet since I'm troubleshooting this. I can put that in later), I have a msgbox and want the value to stay in the textbox, but for it to regain the focus. Here's what I have so far
Public Sub InvoiceNumber_Exit(Cancel As Integer
Dim invoicecount As Varian
invoicecount = DCount("[InvoiceNumber]", "T_Invoice", "InvoiceNumber = Forms!F_16!InvoiceNumber"
If invoicecount <> 0 The
MsgBox ("That Invoice already exists for PO#: " & Left(PONumber, 4) & "-" & Right(PONumber, 4) & Chr$(10) & " Please verify it and reenter"
DoCmd.GoToControl "InvoiceNumber
End I
End Su
Public Sub Payment_Enter(
Dim invoicecount As Varian
If invoicecount said:
Can someone please help me out
Thank you in advance
Dere

Cancel is an Argument in the Exit Sub procedure

If invoicecount <> 0 The
MsgBox ("That Invoice already exists for PO#: " & Left(PONumber
4) & "-" & Right(PONumber, 4) & Chr$(10) & " Pleas
verify it and reenter"
Cancel = Tru
End I
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top