Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 26th, 2004, 09:49 PM
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with tables

New to access and coding visual basic please explain in depth. I have what may be a simple question. I have 4 tables, Table1, Table2, Table3, and Table4. I will enter all date in Table1 using a form. The table has about 10 fields; field1, field2, field3….. I would like to have several yes/no fields that determine where the record will go next. If box1 is selected, then a copy of the record will be moved to Table2; If box2 is selected I would like a copy of the record to move to Table3. I would like for this to take place when I’ve pushed a button on the form. The record should be appended to the table it is sent to. One important thing is that the button should turn red and not work after it has been done once, so that the record is not duplicated and so that I know the action has been completed. Not all the fields are the same, I would like to take five out of the 10 fields in Table1 and copy them to Table2 and copy four of the fields from Table1 to Table3.

Lastly, I would like to do a similar function within Tables2 and 3, but would like to move the record to Table4 so that it is no longer in Tables2 and 3. Please help. I’ve been trying to get this to work for some time now. I thought it would be easy, it’s not.

Thank you!


 
Old May 30th, 2004, 01:59 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello firedog,
A little involved, what your asking. I'm not sure how well your VBA is. I'm so so.
My first reaction is to use DAO or ADO. Here's ADO
I'm going to make a lot of assumptions, all the fields on all 4 forms, are named the same, only the table name & form name changes.
On the command button click method...
Dim stTable as String
Dim newRec as ADODB.RecordSet
Set newRec = New ADODB.Recordset

If chkTable1 Then
stTable = "Table1"
ElseIf chkTable2 Then
stTable = "Table2"
ElseIf chkTable3 Then
stTable = "Table3"
ElseIf chkTable4 Then
stTable = "Table4"
End If

NewRec.OpenRecordset stTable,CurrentProject.Connection,adOpenStatic,adL ockOptimistic


NewRec.AddNew
NewRec!Field1 = Me.Field1
NewRec!Field2 = Me!Field2
NewRec!Field3 = Me!Field3
etc...
NewRec.Update

NewRec.close
 set NewRec = Nothing

Rough idea, hope this helps! Good Luck.
Reply if further info needed.








Similar Threads
Thread Thread Starter Forum Replies Last Post
creating tables within tables in access??? carswelljr Access 3 August 23rd, 2006 01:21 PM
Fixed tables and/or fixed bkgrnd in tables slg111875 Dreamweaver (all versions) 1 June 22nd, 2006 02:31 PM
Regarding Tables spraveens HTML Code Clinic 2 October 20th, 2003 04:46 AM
regarding tables spraveens Dreamweaver (all versions) 1 September 24th, 2003 07:21 AM
Tables andy24 Classic ASP Databases 3 July 23rd, 2003 11:09 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.