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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dlookup - what am i doing wrong

Status
Not open for further replies.

Ouch

Programmer
Jul 17, 2001
159
GB

this function splits a multi author field in a form into seperate fields and pastes them into an author table

what i am attemting to do is check in the author table to see if the author exsists if it does get the author_id and go to the next author, if it doesnt paste it in to the author table.

Private Sub Command44_Click()
Set Dbs = CurrentDb

Dim x As Variant
Dim i As Long
Dim luref As String

If [authors] <> Null Then
x = Split([authors], &quot;:&quot;)

For i = 0 To UBound(x)
existluref = &quot;DLookup([luref_id], tbllookups, [Data] = x(i))&quot;

If existluref = Null Then
Set rst = Dbs.OpenRecordset(&quot;tbllookups&quot;)
rst.AddNew
rst![Data] = x(i)
rst![tpref_id] = &quot;AUT&quot;
rst.Update
rst.MoveLast
luref = rst![luref_id]

Set rst = Dbs.OpenRecordset(&quot;tbllink&quot;)
rst.AddNew
rst![bibref_id] = [bibref_id]
rst![tpref_id] = &quot;AUT&quot;
rst![luref_id] = luref
rst.Update
luref = rst![luref_id]

Else
luref = existluref
Set rst = Dbs.OpenRecordset(&quot;tbllink&quot;)
rst.AddNew
rst![bibref_id] = [bibref_id]
rst![tpref_id] = &quot;AUT&quot;
rst![luref_id] = luref
rst.Update
luref = rst![luref_id]

Next i


End Sub
 
Should this:
existluref = &quot;DLookup([luref_id], tbllookups, [Data] = x(i))&quot;

Not be:
existluref = DLookup(&quot;[luref_id]&quot;, &quot;[tblLookups]&quot;, &quot;[Data] = &quot; & x(i))


???? James Goodman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top