enter parameter error

datacontrol

Registered User.
Local time
Today, 11:26
Joined
Jul 16, 2003
Messages
142
I ahve a simple form in which i am testing. I have a text box named "user" which pulls the user name from the system (workstation). When I press apply, I get an enter parameter value for user name.....help please

Option Compare Database
Option Explicit

Private Sub Apply_Click()


End Sub


Private Sub Command12_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = currentdb()
Set rst = db.OpenRecordset("tblce", dbOpenDynaset)

DoCmd.RunSQL "INSERT INTO tblce(tblce_user) VALUES (" & Me.user & ")"
End Sub

Private Sub Detail_Click()

End Sub

Private Sub user_BeforeUpdate(Cancel As Integer)


End Sub
 
Change this line:

oCmd.RunSQL "INSERT INTO tblce(tblce_user) VALUES (" & Me.user & ")"

To

oCmd.RunSQL "INSERT INTO tblce(tblce_user) VALUES ('" & Me.user & "')"
 
Try this:

Option Compare Database
Option Explicit

Private Sub Command12_Click()
DoCmd.RunSQL "INSERT INTO tblce (tblce_user) VALUES ('" & Me.user & "')"
End Sub

You had lots of extraneous code which I removed. I also added single quotes around the user name.
 
works awesome

Thanks so much for the help....now this works great. I figured it was something simple.

Do the extra apostrophies act as some sort of text qualifier, as in a .csv file or something?

Thanks again...

I am learning along the way
 
data,

SQL needs delimiters around data elements like:

Values ('" & Me.SomeString & "')"
values (#" & Me.SomeDate & "#)"
values (" & Me.SomeNumber & ")"

Wayne
 
tab order

One last thing...

I am using this from as a template for about 20 others. When the user tabs through my fields, they jump all over the form. Is there a way (I am sure there is) to put these in order so that it flows?

Thanks
 
okay 2 more things

is there a way to creat a "clear" button? one that will clear the contents so users can start over?
 
Re: tab order

datacontrol said:
When the user tabs through my fields, they jump all over the form. Is there a way (I am sure there is) to put these in order so that it flows?
Yes it is, look at the View-menu, Tab-order.
Objects that can have a Tab-stop do also have a Tab-index property, look at the properties of the control.

datacontrol said:
is there a way to creat a "clear" button
Try creating a Delete-query with the build-in query-designer, change to SQL-mode and then compare that code with that what you use now to add the record.
 
it never ends

Okay, so I am not so much worried about the tab issue at this point. I believe I fixed it.

WHat I now need to do ism ake certain there is something entered in 3 fields. I don't need any validation here, I have 3 fields set to "null" default value and I want to make sure the user keys something into it, other wise I get a generic access error.

I tried using

if Me.rr is null then......

but I get a run time error "null = null"

advice?

:D
 
If IsNull(Fld1) Or IsNull(Fld2) Or IsNull(Fld3) then
Msgbox "Some Values Missing - do nothing"
Else
'run your code here
End if
 

Users who are viewing this thread

Back
Top Bottom