Change Message Box vb

B

Bob

I want to change this code so as that when you select OK it stops the
operation of the button!
Thanks for any help...Bob
.........
If recHorseOwners.EOF = True And recHorseOwners.BOF = True Then
recHorseOwners.Close
Set recHorseOwners = Nothing
MsgBox "This Horse Has No Owner At ALL.", vbApplicationModal +
vbOKOnly + vbInformation

.Fields("CompanyID") = Nz(recTmpOwner.Fields("CompanyID"), 0)
.Fields("InvoiceID") = lngInvoiceID
.Fields("HorseID") = val(tbHorseID.value)
.Fields("HorseName") = tbHorseName1.value
.Fields("FatherName") = tbFatherName.value
.Fields("MotherName") = tbMotherName.value
 
B

Bob

Bob said:
I want to change this code so as that when you select OK it stops the
operation of the button!
Thanks for any help...Bob
........
If recHorseOwners.EOF = True And recHorseOwners.BOF = True Then
recHorseOwners.Close
Set recHorseOwners = Nothing
MsgBox "This Horse Has No Owner At ALL.", vbApplicationModal +
vbOKOnly + vbInformation

.Fields("CompanyID") = Nz(recTmpOwner.Fields("CompanyID"), 0)
.Fields("InvoiceID") = lngInvoiceID
.Fields("HorseID") = val(tbHorseID.value)
.Fields("HorseName") = tbHorseName1.value
.Fields("FatherName") = tbFatherName.value
.Fields("MotherName") = tbMotherName.value

Actually by then it is to late as the Invoice is Distributed, can it be
added into the Distribute code:( This Horse has no owner do you still want
Distribute!)

Private Sub cmdSave_Click()
If tbInvoiceDate.value = "" Or IsNull(tbInvoiceDate.value) = True Then
MsgBox "Date Could Not Be Null/Blank.", vbApplicationModal +
vbCritical + vbOKOnly
Exit Sub
End If
If MsgBox("Do You Want To Distribute?", vbQuestion + vbApplicationModal
+ vbYesNo + vbDefaultButton1, "Intellisoft") = vbYes Then
recInvoice.AddNew
subSetInvoiceValues
recInvoice.Update

subDeleteInvoiceItmdt

subBlankForm
lbOwnerlist1.value = ""
lbOwnerlist1.RowSource = ""

lbOwnerlist1.SetFocus
cmdSave.Enabled = False
bModify = False
End If
Forms!frmModify![lstModify] = Null

End Sub
 
J

John W. Vinson

I want to change this code so as that when you select OK it stops the
operation of the button!
Thanks for any help...Bob
........

Dim iAns As Integer
If recHorseOwners.EOF = True And recHorseOwners.BOF = True Then
recHorseOwners.Close
Set recHorseOwners = Nothing
iAns = MsgBox("This Horse Has No Owner At ALL.",
vbApplicationModal + vbOKOnly + vbInformation)
If iAns = vbOK Then
Exit Sub
Else
.Fields("CompanyID") = Nz(recTmpOwner.Fields("CompanyID"), 0)
.Fields("InvoiceID") = lngInvoiceID
.Fields("HorseID") = val(tbHorseID.value)
.Fields("HorseName") = tbHorseName1.value
.Fields("FatherName") = tbFatherName.value
.Fields("MotherName") = tbMotherName.value

Note that as written the ONLY button the user can click is OK - vbOKOnly - so
your code will never execute. Do you want to use vbOKCancel instead perhaps?

John W. Vinson [MVP]
 
B

Bob

John W. Vinson said:
Dim iAns As Integer
iAns = MsgBox("This Horse Has No Owner At ALL.",
vbApplicationModal + vbOKOnly + vbInformation)
If iAns = vbOK Then
Exit Sub
Else

Note that as written the ONLY button the user can click is OK - vbOKOnly -
so
your code will never execute. Do you want to use vbOKCancel instead
perhaps?

John W. Vinson [MVP]

Thanks John vbOk as a Cancel would be good , but I think by then it is to
late as the Invoice has been Distributed....Thanks...Bob
 
B

Bob

I Did it :)) ............Thanks Bob Yipee

Private Sub cmdSave_Click()
With recInvoice
Dim recHorseOwners As New ADODB.Recordset, dblOwnerPercentAmount As
Double
Dim dblTotal As Double, dblGSTContentsValue As Double

recHorseOwners.Open "SELECT OwnerID,OwnerPercent FROM
tblHorseDetails" _
& " WHERE HorseID=" _
& val(tbHorseID.value) & " AND OwnerID > 0 ORDER BY OwnerID ",
CurrentProject.Connection, adOpenDynamic, adLockOptimistic

If recHorseOwners.EOF = True And recHorseOwners.BOF = True Then
recHorseOwners.Close
Set recHorseOwners = Nothing
MsgBox "This Horse Has No Client Select [CLOSE] " & vbCrLf &
vbCrLf & " Go to Horses and enter a Client before Distributing.",
vbApplicationModal + vbNo + vbInformation
Exit Sub
End If

If MsgBox("Do You Want To Distribute?", vbQuestion + vbApplicationModal
+ vbYesNo + vbDefaultButton1, "Intellisoft") = vbYes Then
recInvoice.AddNew
subSetInvoiceValues
recInvoice.Update


subDeleteInvoiceItmdt

subBlankForm
lbOwnerlist1.value = ""
lbOwnerlist1.RowSource = ""

lbOwnerlist1.SetFocus
cmdSave.Enabled = False
bModify = False
End If

Forms!frmModify![lstModify] = Null
End With
End Sub
 
B

Bob

So all I need now is how to do the same thing with my BATCH distribute
button ...any help with this would be very appreciated...Bob

Private Sub cmdDistributeAllInvoices_Click()
Dim nRtnValue As Integer

nRtnValue = MsgBox("Are you sure you want to Distribute All Invoices?" &
vbCrLf & vbCrLf & "If you choose Yes, all the Invoices will have Invoice
Numbers.", vbCritical + vbYesNo + vbDefaultButton2, "Distribute all
Invoices")
If nRtnValue = vbYes Then
DoCmd.Hourglass True
subSetInvoiceValues
Application.SysCmd acSysCmdSetStatus, "Process is completed."
Application.SysCmd acSysCmdClearStatus
DoCmd.Hourglass False
Me.lstModify.Requery


End If
End Sub
 

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