Connecting Tech Pros Worldwide Help | Site Map

please help

  #1  
Old November 13th, 2005, 12:15 PM
crispycomputers@hotmail.com
Guest
 
Posts: 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

  #2  
Old November 13th, 2005, 12:15 PM
Johnny Meredith
Guest
 
Posts: n/a

re: please help


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

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Its very very urgent Please....Could you please help.plz help in solving queries jenipriya answers 6 July 14th, 2007 10:18 AM
Hotmail Problem Please Help At Least Read! Thanks Kurt Watson answers 0 November 22nd, 2005 03:33 PM
Please,help as soon as you can. Alan Bashy answers 7 July 23rd, 2005 01:48 AM
Hotmail Problem Please Help At Least Read! Thanks Kurt Watson answers 0 July 21st, 2005 07:38 PM
Please help speed up my query! m3ckon answers 2 July 20th, 2005 06:24 AM