Your code is a mess. You need to dimension all variables at the top of the code, not within the code. It will make seeing the problems a lot clearer. What is the need for all the module level variables? But again until you give us a hilited line I am just guessing.
Your first problem is here:
JBrec.FindFirst "JB_JobBidNo = " & strQuote & NextBidNo & strQuote
JBrec is never set
Problem two:
Set db = CurrentDb()
Set db = db.OpenRecordset("JB_Jobs", dbOpenDynaset)
The open recordset method returns a recordset and you are assinging it to db which is dimensioned as a database
No idea what this code does:
NextBidNo = TRrec(1) + 1
This is a waste of code
nextBidNo = 0
If you dimension it as an integer it defauls always to 0. No exception.
This is a waste of code
set db = currentdb
You only use it once, just use currentdb.
Explicitly dimenion dao and ado objects
dim rs as dao.recordset
not
dim rs as recordset
do not need the strQuote = """"
just use '
I have never seen multiple error statements.
'update TRrec
athough this is legit, I think you are begging for a problem with error checking:
TRrec(1)
call the field out so someone knows what is going on
TRrec.fields("fldName)
or
TRrec!FieldName
If you have a subroutine called update, that is a reserved word. Choose another name. Your code will fail:
update TRec
If you are trying to actually update the field
TRec.edit
TRrec!FieldName = somevalue
TRrec.update
{code]
Private Sub Form_Load()
On Error GoTo Err_Label
Dim JBrec As dao.Recordset
Dim TRrec As dao.Recordset
Dim NextBidNo As Integer
Dim selstr As String
selstr = "Select DistinctRow TR_Tax.TR_TaxRate, TR_Tax.TR_BidUsedNo from TR_Tax"
Set TRrec = CurrentDb.OpenRecordset(selstr, dbOpenDynaset)
Set JBrec = something
If TRrec.RecordCount = 0 Then
MsgBox "There are no records from the Employee Time Query"
Else
NextBidNo = TRrec!FieldName + 1
Call myUpdate(TRrec)
JBrec.FindFirst "JB_JobBidNo = '" & NextBidNo & "'"
If Not JBrec.NoMatch Then
MsgBox "Bid Number already in use - try again."
End If
End If
exit_FormLoad:
Exit Sub
Err_Label:
MsgBox Err.description
Resume exit_FormLoad
End Sub
[/code]