insert into a table from a msgbox input

mendesj1

Registered User.
Local time
Yesterday, 19:05
Joined
Nov 9, 2011
Messages
30
trying to take what a user enters into a msg box and insert that value into a new record in a table

Dim SetPrice As Currency

SetPrice = InputBox(Prompt:="Enter New Price Base.", _
Title:="New Price Base", Default:="Enter here")
CurrentDb.Execute "INSERT INTO [PrototypeDatabaseCafe2010].[dbo].[PriceBasis]" ([PriceBase]) Values (& Setprice.Value & ) "


thanks guys
 
thanks for the help so far but still missing how to bound it to a table
 
How did you create your form? Did you do it with a wizard and base it upon a table? That would bind it to that table. If you did it manually, you will need to open the properties for the form and set the record source as the table you want to bind it to. It is on the Data Tab for the Form.

Alan
 
Still trying to take data entered in a msg box i set the value of that text to set price then try to take that and insert it into a sql table

Private Sub Command45_Click()
Dim SetPrice As Currency

SetPrice = InputBox(Prompt:="Enter New Price Base.", _
Title:="New Price Base", Default:="Enter here")

DoCmd.RunSQL ("INSERT INTO [PrototypeDatabaseCafe2010].[dbo].[PriceBasis]([PriceBase])Values (setprice)")

End Sub
 
You need to refrence your variable outside the Sql-string

Code:
Private Sub Command45_Click()
Dim SetPrice As Currency
 
SetPrice = InputBox(Prompt:="Enter New Price Base.", _
Title:="New Price Base", Default:="Enter here")
 
DoCmd.RunSQL "INSERT INTO [PrototypeDatabaseCafe2010].[dbo].([PriceBasis]([PriceBase]) Values [COLOR=red](" & setprice & ")"[/COLOR]
 
End Sub

JR
 
i tried using that change and now get a runtime error 3134
 
run time 3134
syntax error in insert into statement
 
What does each part of this [PrototypeDatabaseCafe2010].[dbo].[PriceBasis] represent?

Is this an ADP?
 
that it the specif database on my sql server with table name and colum name
 
this inserts the value if i run this querry on my sql server and try to insert 2.54 into the table

INSERT
INTO [PrototypeDatabaseCafe2010].[dbo].[PriceBasis]
([PriceBase]
)
VALUES
(2.54)
 
I think that RunSQL will only work for Access tables so perhaps you need Currentdb.Execute.

Are these linked tables?
 
yes they are linked tables sql backend with an access front end
 
yes tryed both ways still not working must be missing something small,
 

Users who are viewing this thread

Back
Top Bottom