Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Runtime error 3251 .. .. WHAT!?

Status
Not open for further replies.

tinymind

Programmer
Nov 9, 2000
90
GB
Thanks! cornerstone for the VB coding .. .. But .. ..

Simple problem .. .. two forms - unbound fields adding data to three tables. If the detail, about to be added is already in the primary table, then I don't want to add the record .. ..

Code from the form to add the details .. .

Private Sub Adddata_Click()

Dim dbs As Database
Dim rst As Recordset
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("Imported_Data")'From table
'Find the unique account number!?
rst.FindFirst (("unique_key") = Me.[Facility] & Me.[account] & Me.[debttype])
'Finding a match, then depending on results do the following:
If rst.NoMatch Then
DoCmd.OpenQuery "NewImp_Add"
DoCmd.OpenQuery "NewAct_Add"
DoCmd.OpenQuery "NewPat_Add"
MsgBox "Added!", vbInformation, "New Account Added"
End If

End Sub

When clicking on the button, it produces a run time 3251 error on the rst.FindFirst coding .. .. Any solutions?
 
hi,

try

dim rst as DAO.recordset

make sure you've got a reference to DAO 3.6 object library

hth

CP U burn

 
Thanks for the reply .. .. but it does not reslove the issue .. ..
 
try changing
Set rst = dbs.OpenRecordset("Imported_Data")
to
Set rst = dbs.OpenRecordset("Imported_Data", dbOpenDynaset)

PaulF
 
sorry,

didn't read the code to well,

leave the dao, so that there's no confusion possible with adodb rst (wherein findfist is not possible)

but:

Set rst = dbs.OpenRecordset("SELECT * FROM Imported_Data")

should do it

cpyuppie
 
Thanks for the help .. .. but I am still having problems as the findfirst .. .. is the code correct?
 
if the unique key is numeric then yes, else no

rst.FindFirst (("unique_key") = '" & Me.[Facility] & Me.[account] & Me.[debttype] & "'")

However if Unique_Key is an index then you should use Seek not FindFirst (unless its a Linked Table)

rst.Index = "Unique_Key"
rst.seek "=", Me.[Facility],Me.[Account],Me.[DebtType]

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top