PC Review


Reply
Thread Tools Rate Thread

Transfering a single record from one table to another using code

 
 
=?Utf-8?B?c3ppdG8=?=
Guest
Posts: n/a
 
      16th Apr 2004
I was wondering if anyone could help me as to how to go about moving a single record from one table to another. I have a table with unused tickets and once it used I need to have a button on a form that when the user clicks it, it transfers the record to a "used" table, and then opens the corresponding "used" form so that the user can enter additional data, such as a used date, and applied to, etc. The records must be kept in seperate tables for tracking purposes so I can't just keep them in the same table and filter the records by query. Right now I'm using code from a basic converted macro

DoCmd.SetWarnings Fals
DoCmd.RunCommand acCmdSelectRecor
DoCmd.RunCommand acCmdCu
DoCmd.Close acForm, "NRAvail
DoCmd.OpenForm "NRUsed", acNormal, "", "", , acNorma
DoCmd.GoToRecord acForm, "NRUsed", acNewRe
DoCmd.RunCommand acCmdPasteAppen
DoCmd.GoToControl "DateUsed
DoCmd.SetWarnings Tru

However this works sporadically at best, sometimes transferring all data, sometimes very little

Any help would be greatly appreciated

thanks
 
Reply With Quote
 
 
 
 
Robin Guest
Guest
Posts: n/a
 
      16th Apr 2004
I'd suggest that in code you

close the first form having stored the a unique id for the
record to a variable

use the docmd.runsql command to append the record to
the 'used' recordset using the variable to identify the
record

again use the docmd.runsql command to delete the record
from the initial recordset using the variable to identify
the record.

open the second form setting the links criteria to the
unique id of the record you've just appended (again using
the variable)

If you are not familiar with sql then it may help you to
write a query and then view it as sql. You will then be
able to copy the sql statement and edit it in your code.

You MUST have a unique field in your record in both the
first and second recordsets in order to identify the
record of interest.

Hope that this helps.


Robin
>-----Original Message-----
>I was wondering if anyone could help me as to how to go

about moving a single record from one table to another. I
have a table with unused tickets and once it used I need
to have a button on a form that when the user clicks it,
it transfers the record to a "used" table, and then opens
the corresponding "used" form so that the user can enter
additional data, such as a used date, and applied to,
etc. The records must be kept in seperate tables for
tracking purposes so I can't just keep them in the same
table and filter the records by query. Right now I'm
using code from a basic converted macro:
>
> DoCmd.SetWarnings False
> DoCmd.RunCommand acCmdSelectRecord
> DoCmd.RunCommand acCmdCut
> DoCmd.Close acForm, "NRAvail"
> DoCmd.OpenForm "NRUsed", acNormal, "", "", , acNormal
> DoCmd.GoToRecord acForm, "NRUsed", acNewRec
> DoCmd.RunCommand acCmdPasteAppend
> DoCmd.GoToControl "DateUsed"
> DoCmd.SetWarnings True
>
>However this works sporadically at best, sometimes

transferring all data, sometimes very little.
>
>Any help would be greatly appreciated.
>
>thanks
>.
>

 
Reply With Quote
 
=?Utf-8?B?c3ppdG8=?=
Guest
Posts: n/a
 
      16th Apr 2004
Thanks that worked out great everything is running smoothly now


----- Robin Guest wrote: ----

I'd suggest that in code you

close the first form having stored the a unique id for the
record to a variabl

use the docmd.runsql command to append the record to
the 'used' recordset using the variable to identify the
recor

again use the docmd.runsql command to delete the record
from the initial recordset using the variable to identify
the record

open the second form setting the links criteria to the
unique id of the record you've just appended (again using
the variable

If you are not familiar with sql then it may help you to
write a query and then view it as sql. You will then be
able to copy the sql statement and edit it in your code

You MUST have a unique field in your record in both the
first and second recordsets in order to identify the
record of interest

Hope that this helps


Robi
>-----Original Message----
>I was wondering if anyone could help me as to how to go

about moving a single record from one table to another. I
have a table with unused tickets and once it used I need
to have a button on a form that when the user clicks it,
it transfers the record to a "used" table, and then opens
the corresponding "used" form so that the user can enter
additional data, such as a used date, and applied to,
etc. The records must be kept in seperate tables for
tracking purposes so I can't just keep them in the same
table and filter the records by query. Right now I'm
using code from a basic converted macro
>> DoCmd.SetWarnings Fals

> DoCmd.RunCommand acCmdSelectRecor
> DoCmd.RunCommand acCmdCu
> DoCmd.Close acForm, "NRAvail
> DoCmd.OpenForm "NRUsed", acNormal, "", "", , acNorma
> DoCmd.GoToRecord acForm, "NRUsed", acNewRe
> DoCmd.RunCommand acCmdPasteAppen
> DoCmd.GoToControl "DateUsed
> DoCmd.SetWarnings Tru
>>However this works sporadically at best, sometimes

transferring all data, sometimes very little
>>Any help would be greatly appreciated
>>thank

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Single Field/Record Table Tee See Microsoft Access Getting Started 5 30th Jan 2006 06:52 AM
Validating field within print single record code =?Utf-8?B?S2FybCBI?= Microsoft Access 1 6th Nov 2005 07:00 PM
Secure single record in table =?Utf-8?B?WnVybg==?= Microsoft Access Security 2 29th Aug 2005 09:16 AM
Append single record to another table =?Utf-8?B?UmVuZWU=?= Microsoft Access Forms 3 10th Aug 2005 05:55 PM
Help merging a single record from one table to another. Ynot Microsoft Access Getting Started 1 13th Jan 2004 08:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:13 PM.