Run-time error '3001' invalid argument (1 Viewer)

str33ty

Registered User.
Local time
Today, 08:51
Joined
Jun 2, 2008
Messages
30
I can't seem to understand why this doesn't work. i copied and pasted it from a previous project and worked like a dream. and yes, tblScout does exist!
(erroneous line in bold)

Option Compare Database
Dim Rsttable As Recordset

Private Sub cmdadd_Click()

If IsNull(firstname) = True Then
MsgBox "Please enter a First Name"
firstname.SetFocus
Else

If IsNull(surname) = True Then
MsgBox "Please enter a Last Name"
surname.SetFocus
Else

Set Rsttable = CurrentDb.OpenRecordset("tblScout", dbOpenDynaset)
Rsttable.AddNew
Rsttable!firstname = firstname
Rsttable!surname = surname
Rsttable!DOB = DOB
Rsttable!address1 = address1
Rsttable!Address2 = Address2
Rsttable!Address3 = Address3
Rsttable!postcode = postcode
Rsttable!phone1 = phone1
Rsttable!phone2 = phone2
Rsttable!email = email


Rsttable.Update
Rsttable.Close

MsgBox "" & firstname & " " & LastName & " was successfully added."

DoCmd.Close
End If
End If
End Sub

any idea?
 

boblarson

Smeghead
Local time
Today, 08:51
Joined
Jan 12, 2001
Messages
32,059
Try changing this line:
Dim Rsttable As Recordset

to this:

Dim Rsttable As DAO.Recordset


.
 

str33ty

Registered User.
Local time
Today, 08:51
Joined
Jun 2, 2008
Messages
30
hmm thanks for the speedy response, unfortunately i didn't work as i now get an information box saying:

The expression On Click you entered as the event property setting produced the following error: User-defined type not defined
  • The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
  • There may have been an error evalutating the function, event, or macro

any clues?
 

boblarson

Smeghead
Local time
Today, 08:51
Joined
Jan 12, 2001
Messages
32,059
hmm thanks for the speedy response, unfortunately i didn't work as i now get an information box saying:

The expression On Click you entered as the event property setting produced the following error: User-defined type not defined
  • The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
  • There may have been an error evalutating the function, event, or macro

any clues?

Then you need to check to see if you have a Microsoft DAO reference checked. Go to the VBA window and to TOOLS > REFERENCES and check to see if you have MICROSOFT DAO 3.x (where X could be .51, or .6 whichever is on your machine).
 

str33ty

Registered User.
Local time
Today, 08:51
Joined
Jun 2, 2008
Messages
30
excellent. thank you!

one last thing (more of a cosmetic problem) when i view my form i have the view/navigate record arrows at the bottom, how do i get rid of these?
 

boblarson

Smeghead
Local time
Today, 08:51
Joined
Jan 12, 2001
Messages
32,059
excellent. thank you!

one last thing (more of a cosmetic problem) when i view my form i have the view/navigate record arrows at the bottom, how do i get rid of these?

There's a form property in the property dialog (on the Format tab and on the ALL tab) called Navigation buttons - set it to NO.
 

str33ty

Registered User.
Local time
Today, 08:51
Joined
Jun 2, 2008
Messages
30
legend. thank you!

(its been a while since i've opened access!)
 

Users who are viewing this thread

Top Bottom