Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 13th, 2005, 12:15 PM
crispycomputers@hotmail.com
Guest
 
Posts: n/a
Default please help

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
Default 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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles