By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

Need to close Data in Table "A" and export it to table "B"

P: 10
Ok before I get started let it be known I am the definition of a newbie when it comes to access and VBA. I know very little about access and nothing about VBA. I am in the Army and am tasked with making a maintenance program for medical equipment. I have the database, the query, the forms, and the reports. I was able to figure those out, but there is one thing that is beyond me.

Ok I have three tables call them table "A" table "B" and table "C". Table A holds all my equipment information, table B is for workorders, and table C is for closed or completed workorders. The three are independent of one another. I have a form built to open new workorders, what I need is some way to place a command button in that form that will cut all the data from the currently viewed work order paste it in table C and input the current date in a yet to be determined column.

Now I know what I want to do very clearly but three 5 hour days of google searching and reading Access for dummies has only confused me more, and help will save my sanity.
Sep 18 '06 #1
Share this Question
Share on Google+
5 Replies


P: 5
try this idea:

supposing you are viewing your workorders in a form called frmOpenWorkOrder

build two queries one append query and one delete query

Append query: qMove2ClosedWorkOrder
INSERT INTO tableC
SELECT *
FROM tableB
where tableB.id = [forms].[frmOpenWorkOrder].[id]

Delete query: qRemoveFromOpenWorkOrder
DELETE [id]
FROM tableB
where tableB.id = [forms].[frmOpenWorkOrder].[id]

add a command button in your form, right click on the button and go to its properties and select the on click event.
click on the triple dots(...) next to it and select code builder.

in the code builder write something like this:

docmd.openquery "qMove2ClosedWorkOrder"
docmd.openquery "qRemoveFromOpenWorkOrder"

to add a timestamp, add a column to tableC and update the field to Now() in the append query

hope this helps

Ok before I get started let it be known I am the definition of a newbie when it comes to access and VBA. I know very little about access and nothing about VBA. I am in the Army and am tasked with making a maintenance program for medical equipment. I have the database, the query, the forms, and the reports. I was able to figure those out, but there is one thing that is beyond me.

Ok I have three tables call them table "A" table "B" and table "C". Table A holds all my equipment information, table B is for workorders, and table C is for closed or completed workorders. The three are independent of one another. I have a form built to open new workorders, what I need is some way to place a command button in that form that will cut all the data from the currently viewed work order paste it in table C and input the current date in a yet to be determined column.

Now I know what I want to do very clearly but three 5 hour days of google searching and reading Access for dummies has only confused me more, and help will save my sanity.
Sep 18 '06 #2

P: 10
When I run this query what are my parameters? No matter what I type it does nothing. Access takes the code but either I'm doing it wrong or it doesn't work.

in the feild area
Expand|Select|Wrap|Line Numbers
  1. Expr1: "Append query: qMove2ClosedWorkOrder INSERT INTO Closed WO's SELECT * FROM WO REG where WO REG.id"
In the criteria area this is what it says.
Expand|Select|Wrap|Line Numbers
  1. [forms].[New Workorder].[id]
then when I run the code it askes for a parameter, and I don't know what to put, I tired different things and it all came back empty.

If some one is willing I can e-mail what I have.
Sep 18 '06 #3

P: 5
What does your form display? The idea behind this was that if your form displays a unique id for the workorder you can pick it out by doing [forms]![nameofyourform]![nameoftextboxdisplayingid].value

When I run this query what are my parameters? No matter what I type it does nothing. Access takes the code but either I'm doing it wrong or it doesn't work.

in the feild area
Expand|Select|Wrap|Line Numbers
  1. Expr1: "Append query: qMove2ClosedWorkOrder INSERT INTO Closed WO's SELECT * FROM WO REG where WO REG.id"
In the criteria area this is what it says.
Expand|Select|Wrap|Line Numbers
  1. [forms].[New Workorder].[id]
then when I run the code it askes for a parameter, and I don't know what to put, I tired different things and it all came back empty.

If some one is willing I can e-mail what I have.
Sep 19 '06 #4

P: 10
I really am grateful for your help, but when I say I know very little I mean it. I have no idea how to write code or even where to write, I opened up the query in sql view and put in what you suggetsted and access beeped at me. So I tried using the help feature and this is what it gave me.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [CLOSED WO'S] ( WO, MMCN, TECH, NOMIN, FUALTS, TYPE, [SECTION], CLOSEDATE, OPENDATE )
  2. SELECT [WO REG].WO, [WO REG].MMCN, [WO REG].TECH, [WO REG].NOMIN, [WO REG].FUALTS, [WO REG].TYPE, [WO REG].SECTION, [WO REG].CLOSEDATE, [WO REG].OPENDATE
  3. FROM [CLOSED WO], [EQUIP REG] INNER JOIN [WO REG] ON [EQUIP REG].MMCN=[WO REG].MMCN
  4. WHERE ((([WO REG].WO)=[WHAT WO TO CLOSE?]));
  5.  
The fields are WO, MMCN, TECH, NOMIN, FUALTS, TYPE, SECTION, CLOSEDATE, AND OPENDATE. The table uses the primary index key for field WO. And that is the field I would like to use for the input to "close" the workorder.
but that askes me for a prompt and I put in the WO # which is how the table is indexed and then it warns me I am about to ammend (0) rows, and the query is blank.
Sep 20 '06 #5

P: 5
If this issue is still not resovled I wrote up a quick sample database to show you what I mean, hopefully it should help. if you want it give me your email address and I'll send it to you


I really am grateful for your help, but when I say I know very little I mean it. I have no idea how to write code or even where to write, I opened up the query in sql view and put in what you suggetsted and access beeped at me. So I tried using the help feature and this is what it gave me.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO [CLOSED WO'S] ( WO, MMCN, TECH, NOMIN, FUALTS, TYPE, [SECTION], CLOSEDATE, OPENDATE )
  2. SELECT [WO REG].WO, [WO REG].MMCN, [WO REG].TECH, [WO REG].NOMIN, [WO REG].FUALTS, [WO REG].TYPE, [WO REG].SECTION, [WO REG].CLOSEDATE, [WO REG].OPENDATE
  3. FROM [CLOSED WO], [EQUIP REG] INNER JOIN [WO REG] ON [EQUIP REG].MMCN=[WO REG].MMCN
  4. WHERE ((([WO REG].WO)=[WHAT WO TO CLOSE?]));
  5.  
The fields are WO, MMCN, TECH, NOMIN, FUALTS, TYPE, SECTION, CLOSEDATE, AND OPENDATE. The table uses the primary index key for field WO. And that is the field I would like to use for the input to "close" the workorder.
but that askes me for a prompt and I put in the WO # which is how the table is indexed and then it warns me I am about to ammend (0) rows, and the query is blank.
Sep 25 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.