P
perky2go
I have a form with a button that takes a ID from the form and searches for
related records in a table in the mdb. If it doesn't find a match there,
search on our server for data and append it to a temp table in the mdb. Then
I want to search that temp table and copy the related fields for the matching
record to my form. My code does append the values from the server to the temp
table, but then I get an error message "Operation is not supported for this
type of object"--I think on the line:
rst.FindFirst CritText
Part of the code I'm using is below. Since my second search is nested
within the If..Then..Else, I thought maybe the problem was that I hadn't
closed the previous record set...but adding a rst.close in the Else didn't
help.
Dim varClaim As String
varClaim = txtClaim.Value
Dim dbs As Database, rst As Recordset, CritText As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("CLAIM")
CritText = "ClaimID = " & Chr(34) & varClaim & Chr(34)
rst.FindFirst CritText
If Not rst.NoMatch Then
--then copy values from CLAIM table to my form (this works fine)
txtMbr = rst![MbrFullName] (etc.)
Else
--rst.close (get error with or without this line)
--run query that pulls data from our network server into a table in the mdb
DoCmd.OpenQuery "qappBatchPull"
Set rst = dbs.OpenRecordset("zsysTempBatchPull")
CritText = "ClaimID = " & Chr(34) & varClaim & Chr(34)
--(same claim id so this variable value hasn't changed)
rst.FindFirst CritText ---ERROR MSG
If Not rst.NoMatch Then
txtMbr = rst![MbrFullName] (etc.)
Is the problem confusion over the value of rst?
Something with the FindFirst and looking for a record when there is only one
rec?
Something else altogether?
Thanks for any help!
related records in a table in the mdb. If it doesn't find a match there,
search on our server for data and append it to a temp table in the mdb. Then
I want to search that temp table and copy the related fields for the matching
record to my form. My code does append the values from the server to the temp
table, but then I get an error message "Operation is not supported for this
type of object"--I think on the line:
rst.FindFirst CritText
Part of the code I'm using is below. Since my second search is nested
within the If..Then..Else, I thought maybe the problem was that I hadn't
closed the previous record set...but adding a rst.close in the Else didn't
help.
Dim varClaim As String
varClaim = txtClaim.Value
Dim dbs As Database, rst As Recordset, CritText As String
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("CLAIM")
CritText = "ClaimID = " & Chr(34) & varClaim & Chr(34)
rst.FindFirst CritText
If Not rst.NoMatch Then
--then copy values from CLAIM table to my form (this works fine)
txtMbr = rst![MbrFullName] (etc.)
Else
--rst.close (get error with or without this line)
--run query that pulls data from our network server into a table in the mdb
DoCmd.OpenQuery "qappBatchPull"
Set rst = dbs.OpenRecordset("zsysTempBatchPull")
CritText = "ClaimID = " & Chr(34) & varClaim & Chr(34)
--(same claim id so this variable value hasn't changed)
rst.FindFirst CritText ---ERROR MSG
If Not rst.NoMatch Then
txtMbr = rst![MbrFullName] (etc.)
Is the problem confusion over the value of rst?
Something with the FindFirst and looking for a record when there is only one
rec?
Something else altogether?
Thanks for any help!