Joshua61679
Technical User
Im running this code. I'm not quite sure its all doing what it is supposed to yet, but I need to figure out this FindRecord is not available now error. I've double checked to make sure that both pop-up and modal are set to no. Sorry for the link, but I wanted to make sure that I wan't missing something stupid early on that was causing the problem. Thanks.
Private Sub CasedHole_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim strWhere As String
Dim strWhere1 As String
Dim strCustomer As String
Dim strLease As String
Dim strCallSheet As String
Dim strMsg As String
Set db = CurrentDb
strCustomer = Me!Customer
strLease = Me!Lease
strWhere = " WHERE Customer = '" & strCustomer & "' AND " _
& " Lease = '" & strLease & "'"
strWhere1 = " Customer = '" & strCustomer & "' AND " _
& " Lease = '" & strLease & "'"
strSql = "SELECT Customer, Lease " _
& " FROM NewJob " & strWhere
strMsg = "There is already a job record for this service on this well, would you like to create a new job?"
Set rst = db.OpenRecordset(strSql, dbOpenSnapshot)
If (rst.BOF And rst.EOF) Then
Call DoCmd.OpenForm("Cased1", , , , acFormAdd)
Forms!Cased1!Customer = strCustomer
Forms!Cased1!Lease = strLease
Forms!Cased1!CallSheet = rst.RecordCount + 1
Else
Response = MsgBox(strMsg, vbYesNo)
If Response = vbYes Then
Call DoCmd.OpenForm("Cased1", , , strWhere1, acFormEdit)
DoCmd.FindRecord (strWhere)
DoCmd.FindNext
Else
Call DoCmd.OpenForm("Cased1"
DoCmd.Close
End If
End If
rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
Exit Sub
Error:
Call MsgBox(Err.Number & ": " & Err.Description)
End Sub
Private Sub CasedHole_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim strWhere As String
Dim strWhere1 As String
Dim strCustomer As String
Dim strLease As String
Dim strCallSheet As String
Dim strMsg As String
Set db = CurrentDb
strCustomer = Me!Customer
strLease = Me!Lease
strWhere = " WHERE Customer = '" & strCustomer & "' AND " _
& " Lease = '" & strLease & "'"
strWhere1 = " Customer = '" & strCustomer & "' AND " _
& " Lease = '" & strLease & "'"
strSql = "SELECT Customer, Lease " _
& " FROM NewJob " & strWhere
strMsg = "There is already a job record for this service on this well, would you like to create a new job?"
Set rst = db.OpenRecordset(strSql, dbOpenSnapshot)
If (rst.BOF And rst.EOF) Then
Call DoCmd.OpenForm("Cased1", , , , acFormAdd)
Forms!Cased1!Customer = strCustomer
Forms!Cased1!Lease = strLease
Forms!Cased1!CallSheet = rst.RecordCount + 1
Else
Response = MsgBox(strMsg, vbYesNo)
If Response = vbYes Then
Call DoCmd.OpenForm("Cased1", , , strWhere1, acFormEdit)
DoCmd.FindRecord (strWhere)
DoCmd.FindNext
Else
Call DoCmd.OpenForm("Cased1"
DoCmd.Close
End If
End If
rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
Exit Sub
Error:
Call MsgBox(Err.Number & ": " & Err.Description)
End Sub