I have a procedure that makes a call to check to see if there is a record with a nz(ClientDateInvoice) <> 0 and nz(ClientInvoiceNumber) <> 0 it then sets a flag bolMultiInvoice.
The problem is that I'm on a subform continuous forms on the Form_AfterUpdate event i change data on a record and then want to check to see if there is a recored that contains both an invoice number and invoice date and set the flag to do something else - code below. If i requery the recordset i lose the record position. I seem to have to move the focus to two records before the flag kicks in. A timing data update issue any suggestions.
this works but i lose the record focus
'Dim strsql As String
'strsql = "qselSubMultiInvoice"
'Me.RecordSource = strsql
ive also tried
'lngPos = Me.Recordset.AbsolutePosition
'If lngPos > (Me.Recordset.RecordCount - 1) Then
' lngPos = Me.Recordset.RecordCount - 1
' End If
'Me.Recordset.AbsolutePosition = lngPos
but if I click on another record it goes back to the one that i was editing
The procedure
Call CheckJobInformation(bolJobEvent, bolRemedialWork, bolMultiInvoice, Me.Parent.Parent!txtEstimateNumber)
Calling ......
Call OpenDbConnection
strsql = "SELECT TJob.JobID, TEstimates.EstimateId, TWorkAttention.WorkAttentionId, TWorkAttention.JobId, TRemedialWork.RemedialId, TRemedialWork.RemedialJobId, TEstimateWorkType.ClientInvoiceNumber, TEstimateWorkType.ClientDateInvoice " _
& "FROM (((TEstimates INNER JOIN TJob ON TEstimates.EstimateId = TJob.EstimateJobID) LEFT JOIN TWorkAttention ON TJob.JobID = TWorkAttention.JobId) INNER JOIN TEstimateWorkType ON TEstimates.EstimateId = TEstimateWorkType.EstimateIdWorkTypeID) LEFT JOIN TRemedialWork ON TJob.JobID = TRemedialWork.RemedialJobId " _
& "WHERE (((TEstimates.EstimateId) = " & strEstimateNo & "))"
Set rst = New adodb.Recordset
Set rst.ActiveConnection = dbcon
rst.CursorLocation = adUseClient
rst.Open strsql, dbcon, adOpenDynamic
With rst
' checks to see if there are records - not eof or not bof
If (.EOF = True) Or (.BOF = True) Then
rst.Close
Set rst = Nothing
dbcon.Close
Set dbcon = Nothing
Exit Sub
End If
.MoveLast
.Requery
.MoveFirst
' iterate through the data to see what is active job event, multi invoice, remedials work
Do While Not .EOF
' bolMultiInvoice
If bolMultiInvoice = False Then
If Nz(rst!ClientDateInvoice) <> 0 And Nz(rst!ClientInvoiceNumber) <> 0 Then
bolMultiInvoice = True
End If
End If
' bolRemedialWork
If bolRemedialWork = False Then
If Nz(rst!RemedialId) <> 0 Then
bolRemedialWork = True
End If
End If
' bolJobEvent
If bolJobEvent = False Then
If Nz(rst!WorkAttentionId) <> 0 Then
bolJobEvent = True
End If
End If
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbcon.Close
Set dbcon = Nothing
Suggestions ......
The problem is that I'm on a subform continuous forms on the Form_AfterUpdate event i change data on a record and then want to check to see if there is a recored that contains both an invoice number and invoice date and set the flag to do something else - code below. If i requery the recordset i lose the record position. I seem to have to move the focus to two records before the flag kicks in. A timing data update issue any suggestions.
this works but i lose the record focus
'Dim strsql As String
'strsql = "qselSubMultiInvoice"
'Me.RecordSource = strsql
ive also tried
'lngPos = Me.Recordset.AbsolutePosition
'If lngPos > (Me.Recordset.RecordCount - 1) Then
' lngPos = Me.Recordset.RecordCount - 1
' End If
'Me.Recordset.AbsolutePosition = lngPos
but if I click on another record it goes back to the one that i was editing
The procedure
Call CheckJobInformation(bolJobEvent, bolRemedialWork, bolMultiInvoice, Me.Parent.Parent!txtEstimateNumber)
Calling ......
Call OpenDbConnection
strsql = "SELECT TJob.JobID, TEstimates.EstimateId, TWorkAttention.WorkAttentionId, TWorkAttention.JobId, TRemedialWork.RemedialId, TRemedialWork.RemedialJobId, TEstimateWorkType.ClientInvoiceNumber, TEstimateWorkType.ClientDateInvoice " _
& "FROM (((TEstimates INNER JOIN TJob ON TEstimates.EstimateId = TJob.EstimateJobID) LEFT JOIN TWorkAttention ON TJob.JobID = TWorkAttention.JobId) INNER JOIN TEstimateWorkType ON TEstimates.EstimateId = TEstimateWorkType.EstimateIdWorkTypeID) LEFT JOIN TRemedialWork ON TJob.JobID = TRemedialWork.RemedialJobId " _
& "WHERE (((TEstimates.EstimateId) = " & strEstimateNo & "))"
Set rst = New adodb.Recordset
Set rst.ActiveConnection = dbcon
rst.CursorLocation = adUseClient
rst.Open strsql, dbcon, adOpenDynamic
With rst
' checks to see if there are records - not eof or not bof
If (.EOF = True) Or (.BOF = True) Then
rst.Close
Set rst = Nothing
dbcon.Close
Set dbcon = Nothing
Exit Sub
End If
.MoveLast
.Requery
.MoveFirst
' iterate through the data to see what is active job event, multi invoice, remedials work
Do While Not .EOF
' bolMultiInvoice
If bolMultiInvoice = False Then
If Nz(rst!ClientDateInvoice) <> 0 And Nz(rst!ClientInvoiceNumber) <> 0 Then
bolMultiInvoice = True
End If
End If
' bolRemedialWork
If bolRemedialWork = False Then
If Nz(rst!RemedialId) <> 0 Then
bolRemedialWork = True
End If
End If
' bolJobEvent
If bolJobEvent = False Then
If Nz(rst!WorkAttentionId) <> 0 Then
bolJobEvent = True
End If
End If
.MoveNext
Loop
End With
rst.Close
Set rst = Nothing
dbcon.Close
Set dbcon = Nothing
Suggestions ......