B
Brad Holderman
Greetings,
I am currently using Access 2000 to run a document image database and have
run into a bit of a issue with coding in some buttons.
For the most part, starting with a switchboard menu I want to open a form
running off a query to search records. My goal is if No records are found,
the code takes me into the form with a new record. If cancel is clicked, I
want to go back out to the previous switchboard.
The first batch of code is what is running so far. But there are 2 things.
First, for some reason, coding the vbCancel button to open a new record
causes the OK button to do this, and vice versa which seems backwards to what
I am trying to write.
Second, in trying to write a second If..Then for the actual Cancel button,
it simply passes me into the form, but I want to go back out to the
switchboard. I pasted what I wrote in my attempts at that, as the "Second
try." Any help would be appreciated.
Code running so far:
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
stDocName = "frmPerCustomer"
If Me.Recordset.RecordCount = 0 Then
strMessage = "Job Not found, click OK to Continue."
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbCancel Then
DoCmd.Close
DoCmd.OpenForm stDocName, acNewRecord
End If
End If
End Sub
Second try:
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
stDocName = "frmPerCustomer"
If Me.Recordset.RecordCount = 0 Then
strMessage = "Job Not found, click OK to Continue."
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbOK Then
DoCmd.Close
DoCmd.OpenForm stDocName, acNewRecord
End If
If bytChoice = vbCancel Then
DoCmd.Close
DoCmd.OpenForm "frmSearchMenu", acNormal
End If
End Sub
I am currently using Access 2000 to run a document image database and have
run into a bit of a issue with coding in some buttons.
For the most part, starting with a switchboard menu I want to open a form
running off a query to search records. My goal is if No records are found,
the code takes me into the form with a new record. If cancel is clicked, I
want to go back out to the previous switchboard.
The first batch of code is what is running so far. But there are 2 things.
First, for some reason, coding the vbCancel button to open a new record
causes the OK button to do this, and vice versa which seems backwards to what
I am trying to write.
Second, in trying to write a second If..Then for the actual Cancel button,
it simply passes me into the form, but I want to go back out to the
switchboard. I pasted what I wrote in my attempts at that, as the "Second
try." Any help would be appreciated.
Code running so far:
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
stDocName = "frmPerCustomer"
If Me.Recordset.RecordCount = 0 Then
strMessage = "Job Not found, click OK to Continue."
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbCancel Then
DoCmd.Close
DoCmd.OpenForm stDocName, acNewRecord
End If
End If
End Sub
Second try:
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte
stDocName = "frmPerCustomer"
If Me.Recordset.RecordCount = 0 Then
strMessage = "Job Not found, click OK to Continue."
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbOK Then
DoCmd.Close
DoCmd.OpenForm stDocName, acNewRecord
End If
If bytChoice = vbCancel Then
DoCmd.Close
DoCmd.OpenForm "frmSearchMenu", acNormal
End If
End Sub