Lookup record is not working

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I had this look up working great and now it's not working. Not sure what
changed in my code.

It seems to be failing at the stLink = "[RGAID]=" & SID

The RGAID is a number feild. So I am wondering if I have to change the AS
String to AS Integer. I am getting an error TYPE MISS MATCH 13. I tried it
with AS Integer and it still error's out.

Private Sub Combo41_AfterUpdate()
On Error GoTo ErrorHandler
' Find the record that matches the control.
Dim SID As String
Dim stLink As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone

SID = Me.Combo41.Value
stLink = "[RGAID]=" & SID

'Check table for for item number.
If DCount("RGAID", "qryRGASource", stLink) >= 1 Then
'Go to record of original Number
rsc.FindFirst stLink
Me.Bookmark = rsc.Bookmark
Else
'Message box warning that item doesn't exsist.

MsgBox "Warning RGA " _
& SID & " is not a valid RGA." _
& vbCr & vbCr & "Call someone who cares.", vbExclamation _
, "RGA NOT FOUND"

End If
Set rsc = Nothing

ErrorHandler:
MsgBox "Error#: " & Err.Number & vbCrLf & Err.DESCRIPTION

End Sub
 
S

strive4peace

try

if it is an Autonumber, or long integer, dimension it
AS Long

here is some code I always use:

'~~~~~~~~~~~~
Private Function FindRecord()

'thanks for ideas, freakazeud

If IsNull(Me.ActiveControl) Then Exit Function

'save current record if changes were made
If me.dirty then me.dirty = false

Dim mRecordID As Long
mRecordID = Me.ActiveControl
Me.ActiveControl = Null
Me.RecordsetClone.FindFirst "IDfield = " & mRecordID

If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Exit Function
End If

End Function
'~~~~~~~~~~~~~~~~~~~

then, you can use
=findRecord()

on the AfterUpdate event of several controls -- as long as
the first column is the record id ... works great!

Warm Regards,
Crystal
Microsoft Access MVP 2006

*
Have an awesome day ;)

remote programming and training
strive4peace2006 at yahoo.com

*
 

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

Similar Threads


Top