Problem w/VBA Code

A

Anthony Viscomi

I have the following:

Function RunUpdate()
DoCmd.SetWarnings False

Dim dbCurr As DAO.Database
Dim qdfCurr As DAO.QueryDef
Dim qdf As QueryDef
Dim sSQL As String
Dim db As Database
Dim prmSupplier As Parameter

Dim rs As Recordset

sSQL = "SELECT [Vendor].*"
sSQL = sSQL & " FROM [Vendor];"
Set db = CurrentDb()
Set rs = db.OpenRecordset(sSQL, dbOpenDynaset)

With rs

If .RecordCount > 0 Then

.MoveFirst

Do Until .EOF

For Each qdfCurr In db.QueryDefs

If InStr(qdfCurr.Name, "849 Pull Vendor") = 1 Then

If qdfCurr.Name = "849 Pull Vendor 100 Build NE 0" Then

Set qdfCurr = db.QueryDefs("849 Pull Vendor 100 Build NE
0")

Set prmSupplier = qdfCurr.Parameters![Supplier]

prmSupplier = Fields(1).Value

qdfCurr.Execute

Else

DoCmd.OpenQuery qdfCurr.Name

End If

End If

Next qdfCurr

.MoveNext

Loop

End If

End With

rs.Close

Set rs = Nothing
End Function

I keep receiving the "Sub or Function not defined error" for the Fields in
the line:
prmSupplier = Fields(1).Value

I received this function from a co-worker and it runs fine on his machine;
any thoughts?

Thanks!
Anthony
 
G

Graeme Richardson

Hi Anthony, Fields(1) is interpreted as function and not a
property/collection of the rs object.

prmSupplier = Fields(1).Value
s/be
prmSupplier = .Fields(1).Value

Graeme.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top