Select fields on a form and put this data into a specific table.

G

Guest

Hi! I’m trying to find the answer to this problem:

I made a form where users can put their data in.
This form has a date-field, a text-field and a field witch content a
numbers. I made a Submit button, and I want that the above mentioned fields
(in this specific form) will be selected by a query (or something like that)
and will be stored in my table "T_OE_Ideas_Queried".

Does anyone know how to do this via a query or VBA?

Kind regards, Stefan van der Hooft.
 
G

Guest

In VBA you could use the following SQL statement:

Dim MYSQL as String
MYSQL = "INSERT INTO T_OE_Ideas_Queried
([Field1],[Field2],[Field3]......[Field20]) VALUES ("' & Textbox1.Value &
"','" & TextBox2.Value & "','" & TextBox3.Value & "')"
With DoCmd.
.SetWarnings False
.RunSQL MYSQL
.SetWarnings True
End With

HTH,
Don't forget to rate me as helpful If I have answered your question!
 
G

Guest

Hi!
Unfortunately the code doesn’t work, I get a Syntax error. I will explain
further on:

The name (in the database) of the first fields is Date, the second is
Open_CC and the third is Open_WM.
The name (on my form) of the first field is Field_Date, the second is
Field_CC and the third is Field_WM.

Please can you help me?


ashg657 said:
In VBA you could use the following SQL statement:

Dim MYSQL as String
MYSQL = "INSERT INTO T_OE_Ideas_Queried
([Field1],[Field2],[Field3]......[Field20]) VALUES ("' & Textbox1.Value &
"','" & TextBox2.Value & "','" & TextBox3.Value & "')"
With DoCmd.
.SetWarnings False
.RunSQL MYSQL
.SetWarnings True
End With

HTH,
Don't forget to rate me as helpful If I have answered your question!
Stefan van der Hooft said:
Hi! I’m trying to find the answer to this problem:

I made a form where users can put their data in.
This form has a date-field, a text-field and a field witch content a
numbers. I made a Submit button, and I want that the above mentioned fields
(in this specific form) will be selected by a query (or something like that)
and will be stored in my table "T_OE_Ideas_Queried".

Does anyone know how to do this via a query or VBA?

Kind regards, Stefan van der Hooft.
 
G

Guest

Using the word Date as a field name will cause problems for you since this is
a word used to define a built in access function to retrieve the current
system date.

Try renaming your field date to something else, in the code below I called
it "fldDate":

Dim MYSQL as String
MYSQL = "INSERT INTO T_OE_Ideas_Queried ([fldDate],[Open_CC],[Open_WM])
VALUES ([Field_Date],[Field_CC],[Field_WM])"
With DoCmd
..SetWarnings False
..RunSQL MYSQL
..SetWarnings True
End With

If you're still getting that Syntax error then please could you inform me
which error this is being displayed with the error code. Many thanks.

Hope that helps.

Stefan van der Hooft said:
Hi!
Unfortunately the code doesn’t work, I get a Syntax error. I will explain
further on:

The name (in the database) of the first fields is Date, the second is
Open_CC and the third is Open_WM.
The name (on my form) of the first field is Field_Date, the second is
Field_CC and the third is Field_WM.

Please can you help me?


ashg657 said:
In VBA you could use the following SQL statement:

Dim MYSQL as String
MYSQL = "INSERT INTO T_OE_Ideas_Queried
([Field1],[Field2],[Field3]......[Field20]) VALUES ("' & Textbox1.Value &
"','" & TextBox2.Value & "','" & TextBox3.Value & "')"
With DoCmd.
.SetWarnings False
.RunSQL MYSQL
.SetWarnings True
End With

HTH,
Don't forget to rate me as helpful If I have answered your question!
Stefan van der Hooft said:
Hi! I’m trying to find the answer to this problem:

I made a form where users can put their data in.
This form has a date-field, a text-field and a field witch content a
numbers. I made a Submit button, and I want that the above mentioned fields
(in this specific form) will be selected by a query (or something like that)
and will be stored in my table "T_OE_Ideas_Queried".

Does anyone know how to do this via a query or VBA?

Kind regards, Stefan van der Hooft.
 

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

Top