Write values to DB on click

fluidmind

Registered User.
Local time
Today, 12:23
Joined
Jun 30, 2006
Messages
66
Hi there!

This is a question that you might scratch your head while reading, but what the hell... :-)

Imagine a form with 4 blank textboxes (name, input1, input2, input3). When you add the value in the textboxes, the value in the table changes as you write. Instead I only want the values in the table to be added once an "OK" button has been pressed.

When the button is pressed I want the current date written in a field called 'date' and the inputs from the 4 textboxes added to fields with the same name...

How is that done???

John
 
Please help :)

Hey again!

It is really important that I understand this principle, since it is a cruscial element in my db-programming. It might seem simple, but the more I need to understand it...:-)

Thanks in advance!
 
fluidmind said:
Hi there!

This is a question that you might scratch your head while reading, but what the hell... :-)

Imagine a form with 4 blank textboxes (name, input1, input2, input3). When you add the value in the textboxes, the value in the table changes as you write. Instead I only want the values in the table to be added once an "OK" button has been pressed.

When the button is pressed I want the current date written in a field called 'date' and the inputs from the 4 textboxes added to fields with the same name...

How is that done???

John

Best way would probably be to make an unbound form with unbound textboxes. Then a button, btnSaveMe and code:

Dim strSaveData as String

strSaveData = "INSERT INTO tblSomething(field1,field2,field3,field4) " _
& "SELECT field1,field2,field3,field4 " _
& "FROM tblUnbound " _
& "WHERE unboundID = " & Me!frmUnbound

CurrentDb.Execute strSaveData, dbFailOnError

Me!txtField1.Text = ""
etc

Wrap the code in its own err handler if code is part of larger code text.
 
Last edited:
OR

Let's say the fields in the table you want updated on click were "field1", "field2" and "field3".

Put those fields in the form bound to the right place and hide them.
Create 3 new textboxes that are unbound and call them "txtField1" etc...

In the onclick event, just put:
field1 = txtfield1

depends how simple you want it.
 
The man once again

Hi both!

Thanks for the replies. I fixed the problem using Mike's suggestion. I sounded a little simpler...

You're the man once again, Mike. Thanx!

// JR
 

Users who are viewing this thread

Back
Top Bottom