Hi everyone,
Today I did run into a weird problem. For the first time I wanted to use the "Seek" function in a small program and test the result with ".NoMatch".
The strange thing is that after the Seek-function, in the new code line of the name of the recordset "NoMatch" was not among the properties I could select. These are the two lines of code (see for the compete code below):
When I typed "nomatch" manually, Access seems to recognise it (it turned "nomatch" nicely to "NoMatch"), but this is maybe because of the DAO library? But on compiling it doesn't recognise the "NoMatch" property.
So what am I doing wrong? If someone could help me here, that would be great.
Thanks in advance,
Rob.
Today I did run into a weird problem. For the first time I wanted to use the "Seek" function in a small program and test the result with ".NoMatch".
The strange thing is that after the Seek-function, in the new code line of the name of the recordset "NoMatch" was not among the properties I could select. These are the two lines of code (see for the compete code below):
Code:
rstMerchant.Seek "=", intFindID
If rstMerchant.NoMatch Then .....
So what am I doing wrong? If someone could help me here, that would be great.
Thanks in advance,
Rob.
Code:
Dim blnMainLoop As Boolean
Dim intFindID As Integer
Dim strSQLAccount As String
Dim strSQLMerchant As String
Dim cnnAccount As ADODB.Connection
Dim cnnMerchant As ADODB.Connection
Dim rstAccount As ADODB.Recordset
Dim rstMerchant As ADODB.Recordset
' ==================================================================================================
strSQLAccount = "SELECT [Contract-id] FROM [103 Account] UNION ALL " _
& "SELECT Account_ID FROM [161 Reserved Account-Nrs] ORDER BY [contract-id]"
Set cnnAccount = New ADODB.Connection
cnnAccount.Open CurrentProject.BaseConnectionString
Set rstAccount = New ADODB.Recordset
rstAccount.Open strSQLAccount, cnnAccount, adOpenKeyset, adLockOptimistic
strSQLMerchant = "SELECT [Client-id] FROM [100 Merchant] UNION ALL " _
& "SELECT [Client_ID] FROM [163 Reserved Client-Nrs] ORDER BY [Client-ID]"
Set cnnMerchant = New ADODB.Recordset
cnnMerchant.Open CurrentProject.BaseConnectionString
Set rstMerchant = New ADODB.Recordset
rstMerchant.Open strSQLMerchant, cnnMerchant, adOpenKeyset, adLockOptimistic
blnMainLoop = True
intFindID = 0
rstMerchant.Index = "Client-ID"
rstAccount.MoveFirst
Do While (rstAccount.EOF = False) And (blnMainLoop = True)
If (intFindID = 10000) Then
MsgBox "No more free accountnumbers available!!!!", vbCritical
blnMainLoop = False
Else
If (rstAccount![Contract-id] - intFindID) > 1 Then
intFindID = intFindID + 1
rstMerchant.Seek "=", intFindID
If rstMerchant.NoMatch Then
Debug.Print "Should be free: ", intFindID
blnMainLoop = False
End If
End If
Loop
rstMerchant.Close
Set rstMerchant = Nothing
cnnMerchant.Close
Set cnnMerchant = Nothing
rstAccount.Close
Set rstAccount = Nothing
cnnAccount.Close
Set cnnAccount = Nothing