Macro problems

  • Thread starter Thread starter Ghost
  • Start date Start date
G

Ghost

Guest
Hi!

I have a big problem with my database. I want to have a macro to preform this:
I hava a temporary tabel and one order table. When I'm in my form and push a button an order shall be saved in the temporery table. I may place as many order as i like (from same costumer). Then I push another button and the macro shall print the temporary table, to be used with the order package, move the information in the temporary table to the order tabel and then run a deletequestion so the temporary table are empty and ready for new orders.

I have got parts of it to work, but there is a new order table created everytime the macro transfer data. ex. Order, Order 1 :(

How can I do this? Any other solution to my problem?
Plz i need fast solutions!
 
Ghost,

I don't know what your Macro actually does look like...but you could use a couple of Queries in your Macro like an Update Query and an Append Query to update your order table with the temporary data and use an OpenTable (temporary order table) and then 2 RunCommand statements (first: SelectAllRecords and second: DeleteRecord) to empty (and not delete) your temp. table
 
KingKong said:
Ghost,

I don't know what your Macro actually does look like...but you could use a couple of Queries in your Macro like an Update Query and an Append Query to update your order table with the temporary data and use an OpenTable (temporary order table) and then 2 RunCommand statements (first: SelectAllRecords and second: DeleteRecord) to empty (and not delete) your temp. table

Can you be more specific? I'm not that skilld that i know exactly how you mean. Maybe you could show me an exampel?
 
Rich said:
Why do you need another table at all ?

I want the temporary table to contain all orders by one person at the same time. Then this is printed and a guy at the warehouse is fixing the package and put that order paper along in the package. Then the data is transfered to a order table where ALL orders are beinge saved for further use.

Or maybe you have another soulution?

*sorry for my english but it's erly and i'm tired...*
 
Ghost - I have a database which uses a temporary table, from which records are copied to a permanent table before deletion from the temp table. This works fine for me. You will need a macro loop which goes through all the records in your temporary table (TEMP) and copies the data into new records in you permanent table (PERM), before deleting all the records in your temp table in one go using a delete query. The way I have done it is as follows:

Firstly create two forms, one for each of your temporary and permanent tables. In the forms' properties, ensure the sort IDs are your key fields (Here ID). Then create the following macros, one which calls the other...

Macro: COPYANDDELETE
*******************
Echo NO
Open Form TEMP (datamode=Edit, Windowmode=hidden)
GoToRecord TEMP (Record=FIRST)
RunMacro LOOP1 (Repeat expression = Not (IsNull([Forms]![TEMP]![ID]))
OpenQuery DELETETEMP
(This should be a delete query constructed to delete all the records in your Temp table.)
Close TEMP
Echo YES

Macro: LOOP1
***********
OpenForm PERM (datamode=ADD, Windowmode=hidden)
GoToRecord PERM (Record=NEW)
SetValue (Item=[Forms]![PERM]![field1] Expression=[Forms]![TEMP]![field1]
(You will need a Set Value command for each field in you tables.)
Close PERM
GoToRecord TEMP (Record=NEXT)

MatMac.
 

Users who are viewing this thread

Back
Top Bottom