<snip>
I must admit i am not a seasoned VBA programmer. I still cannot get
this to work. The following is the result of reading a number of
posts, articles etc on what i thought was relavant information.
Please help?
Private Sub cmdAddRga_Click()
On Error GoTo Err_cmdAddRga_Click
Dim strSearchName As String
Dim rs As Object
Set rs = Me.Recordset.Clone
strSearchName = InputBox("Enter RGA Number", "Enter New RGA")
rs.FindFirst "[RgaNumber]=" & strSearchName
If Not rs.NoMatch Then
Me.Bookmark = rs.Bookmark
End If
Exit_cmdAddRga_Click:
Exit Sub
Err_cmdAddRga_Click:
MsgBox Err.Description
Resume Exit_cmdAddRga_Click
also can you please explain why DAO or ADO is necessary, many things i
read did not have this as a requirement for working with recordsets?
Access uses either DAO or ADO to communicate with the underlying Jet
database (there are actually other interfaces as well, but DAO and ADO are
the most common). DAO used to be the default, but recent versions of Access
have switched to ADO as the default. That's what you're using in your code,
even if you don't realize it. You don't explain what you mean by 'cannot get
this to work'; are you getting an error or is it just not positioning you to
the record you want? If you're getting an error, you need to post details
about the error.
In either case, my guess is that Access may be confused about which
interface (ADO or DAO) you are using. Open any code window and go to
Tools -> References. You should have either a DAO library (for example,
Microsoft DAO 3.6 Object Library) or an ADO (for example, Microsoft ActiveX
Data Objects 2.8 Library) library checked. Since you apparently haven't done
anything with the references, I'm guessing that the ADO library is checked.
If neither are checked, you need to select one. If both are checked, you
need to either uncheck one of them, or be more specific in your code as to
which interface to use. Then do something like this:
Dim rs as DAO.Recordset ' If the DAO library is checked
or
Dim rs as ADO.Recordset ' If the ADO library is checked
The FindFirst method is only available in DAO recordsets, so I would suggest
that you go with DAO. Otherwise, you'll need to use the Find method of ADO
recordsets. You can look in the Help for more information about these
methods.
One last question: I don't know if this was asked before, but is RgaNumber
defined as a number or text in the table? If it's text, then even if you're
storing a number you'll need to put quotes around the value in the FindFirst
call:
rs.FindFirst "[RgaNumber]='" & strSearchName & "'"
Note that I've included single quotes inside the double quotes. This results
in a string that looks like this:
RgaNumber='1234'
Carl Rapson