By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,964 Members | 1,290 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,964 IT Pros & Developers. It's quick & easy.

please help

P: n/a
i am creating a database for a school registration system. i have
created a form. on the form i have created a button. i want this button
to:

create a new record in the relevent table, then copy one of the fields
in the form to one of the fields in the table. (the table which the
form is pointed to is not the same table which the button is going to)

thank you

Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You'll have to do this with code. Make sure you have a reference set
to DAO (Tools -> References; put a checkmark in Microsoft DAO 3.6).

In the form's declaration section type:

Public Const cDestinationTable = "MyTable"
'Replace MyTable with name of destination table
Public Const cDestinationField = "MyField"
'Replace MyField with name of field in destination table

In the button's onclick event, type (air code):

Dim db as DAO.Database
Dim rec as DAO.Recordset
Dim conMyControl as Control
conMyControl = me.MyControl 'Change MyControl to the control with
the value
Set db = CurrentDB()
With db
Set rec = .OpenRecordSet(cDestinationTable)
With rec
.AddNew
.Fields(cDestinationField) = conMyControl
.Update
.Close
End With
.Close
End With
Set rec = Nothing
Set db = Nothing

Right click on the button you are programming and select Build Event,
then code builder, to get to the buttons onclick event. The
declarations section is the whitespace at the top of this window below
any option statements (Option Explicit, Option Compare Database, etc.)
This should get you started, but please ask any follow-up questions you
need.

Johnny

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.