Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 July 21st, 2003, 08:30 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Copy list box data

Hi,

How can i copy data from a list box to another form. I have designed code to run through each column of the list box, however i am not sure how to copy , say , 3 rows of data to another form. The code is below :

    Set ctl = Me.lstSearchShiftCrew
    For Each varItm In ctl.ItemsSelected
        For intI = 0 To ctl.ColumnCount - 1
        ' Do i insert a code here ? '
        Next intI
    Next varItm

Thanks,

Vlad
__________________
Vlad
Sydney, Australia
 
Old July 22nd, 2003, 06:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by vladimir
How can i copy data from a list box to another form. I have designed code to run through each column of the list box, however i am not sure how to copy , say , 3 rows of data to another form.
Vlad, when two or more forms share listboxes and/or comboboxes, I put the contents of the lists in a table and then populate each list from the table. In this way, there's no need to copy from one form to the other. Also, if the list is updated, you update once to the table rather than update ListA on FormA and then have to copy ListA to ListB on FormB.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old July 22nd, 2003, 08:50 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Greg,

Perhaps i didn't explain this properly. I am creating a Logbook database. Any jobs not completed today, should be carried over to next day. So, essentially, i need to copy today's records to tomorrow's logbook.

The set up is Form-subform and the user should be able to select area and cost centre values from main form, click a button and copy log book entries from subform to a 'new' day.

The problem i'm facing at present is that when i try to append carry over jobs to bottom of the subform table i get "Key violation" error message, because of the way i've set up the referential integrity rules. My dilemma is wether to temporarily delete table relations, insert new rows, then re-enforce the relations or try and find another method of copying records across. Does this make sense to you ?

Vladimir
Australia
 
Old July 23rd, 2003, 06:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Quote:
quote:Originally posted by vladimir
Perhaps i didn't explain this properly. I am creating a Logbook database. Any jobs not completed today, should be carried over to next day. So, essentially, i need to copy today's records to tomorrow's logbook.
Ah, so you're trying to bring "leftovers" from yesterday over to today. In that case, I suggest this: create an extra field in your table for completed tasks. It could be a Complete Date or simply a Yes/No box. When a task for the day is completed, the user either fills in the date or checks the box. The next day, the undone tasks (no complete date or not checked) are either automatically or manually (via a button) appended to today's tasks via an append query.

Quote:
quote:The problem i'm facing at present is that when i try to append carry over jobs to bottom of the subform table i get "Key violation" error message, because of the way i've set up the referential integrity rules. My dilemma is wether to temporarily delete table relations, insert new rows, then re-enforce the relations or try and find another method of copying records across.
I do not recommend do all that to get your data to work. You should re-examine your relationships and make sure that the key field is not violated. Perhaps the key field you currently have is not truly a unique one. Examine picking another or simply creating an autonumber primary key.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old July 23rd, 2003, 03:01 PM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

test

 
Old July 23rd, 2003, 06:23 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Greg,

I have a field that indicates if the job was finished or not and the append query has the field as criteria - JobStatus <> "Complete".

My main table contains field TeamLeaderID as AutoNum, PK. Other fields are TeamLeaderName, Crew. The "child" table contains ID field as AutoNum, PK, TeamLeaderID link as LongInt and other fields. The 1 to many rel. is on TeamLeaderID and i have enforced all ref.integrity rules on the link.

When the user (new TeamLeader) carries over the jobs, he should go to entry form enter his details, then append non-complete jobs from previous day to subform. I think what is creating the problem is that previous days' jobs carry previous teamleader's ID link. If i append as it is, the jobs will remain linked to previous team leader. I need to find a way to append job details and insert new teamLeaderID for every appended job, so that data will show properly in both main and subform.



Vladimir
Australia





Similar Threads
Thread Thread Starter Forum Replies Last Post
copy a list box from a form to a report bjcountry Access 1 April 18th, 2008 03:14 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
representing duplicated data in a list box jaredcat Access 1 July 18th, 2006 12:20 PM
filtering data from a database using list box europhreak Dreamweaver (all versions) 4 September 25th, 2005 04:27 AM
Filling in a list box with data from Access goplayoutside VB Databases Basics 7 April 21st, 2004 08:27 PM





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