Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unbound Forms...Saving fields from form to table

Status
Not open for further replies.

Sparkyg

Programmer
Feb 22, 2005
3
GB
Hi...just a beginner at all this so would really appreciate some help on the following...

I have a database called Client.mdb in this database I have a table called 'tblCustomer_Details_Add' which contains the fields listed below.

Customer_ID
Forename
Surname
Customer_Postcode
Customer_Email

I have a form 'frmCustomer_Details_Add' which is designed to collect the information required to populate the table. My form has the following objects on it

txtCustomer_ID
txtForename
txtSurname
cmbPostcode
txtEmail

Rather than directly linking all the fields on my form to the table I would like to hit a 'Save' button to add the information entered on the form to the appropriate field in the table. Could someone give me the code to do this?
Thanks

 
Hi,

Not sure of a save button but if you want to create an input form and not bind it to the table you can create a command button when pressed runs an append query which adds the fields to the relevant fields in a table. You would use this format on the on click property of the command button:

Dim strSQL As String

strSQL = "INSERT INTO ..." & _
"SELECT...;"
DoCmd.RunSQL strSQL

HTH,
M-.
 
How are ya Sparkyg . . . . .

[ol][li]In the table is [blue]Customer_ID[/blue] [purple]autonumber, numeric (non-autonumber), or Text?[/purple][/li]
[li]In the combobox [blue]cmbPostcode[/blue] which column holds the postcode (index starts at zero). Have a look at the [blue]ColumnWidths[/blue] property to be sure. The display column is always the first non-zero width column.[/li][/ol]

Calvin.gif
See Ya! . . . . . .
 
Hi there TheAceMan1 ...

My Customer_ID is an Autonumber and I have now changed cmbPostcode to a text box, I have also had to add another field to the form and table which is a combo box on the form called cmbPreferred_Brand (it says this in the column widths property ..... 2.54cm;1.191cm)

Cheers Sparkyg
[sunshine]
 
Sparkyg said:
[blue][purple]Rather than directly linking all the fields[/purple] on my form to the table I would like to hit a 'Save' button to add the information entered on the form to the appropriate field in the table.[/blue]
Forgive me [blue]Sparkyg[/blue] but I have to ask: Are you saying the fields on the form are [purple]Unbound![/purple]

Calvin.gif
See Ya! . . . . . .
 
At the moment they are as I -should or should they not be?
 
Sparkyg . . . . .

BTW . . . [blue]Welcome to Tek-Tips![/blue]
Sparkyg said:
[blue]I -should or should they not be?[/blue]
Let me see if I can explain saving in Access and then you can make up your mind better, as far as your post origination is concerned.
[ol][li]When you start editing a record for the first time, you put that record in [blue]Edit Mode[/blue] (as indicated by the [blue]pencil icon[/blue]).[/li]
[li]Now that your in [blue]edit mode[/blue], there are two ways to save a record (as far as manual data is concerned):
[ol a][li]The [purple]user moves the focus to another record.[/purple][/li]
[li]The [purple]user closes the form or the database.[/purple][/li][/ol]
This is considered [blue]Auto-Save[/blue] in Access.[/li]
[li]This normally occurs when the user enters the [blue]last data in the Tab Order[/blue] and Tabs/Enters to the [blue]first field in the Tab Order on the next record.[/blue][/li][/ol]
If a user is not going to do this, or you want more [blue]operational assurance[/blue] of saving records, then a [purple]Save Button[/purple] fits the bill.

As for [blue]bound/unbound[/blue]. An object on a form is bound when its [purple]ControlSource[/purple] property has the name of a field in the underlying table of the Recordsource of the form. The object is unbound otherwise. [purple]Bound objects save data when a record is saved.[/purple] Unbound do not.

So . . . do you really want a save button?

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top