Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Subform using a macro?

Status
Not open for further replies.

data1025

IS-IT--Management
Apr 14, 2004
29
US
I have a form, and subform. The form has computer equpt. information, including serial #. The subform has a list of software installed on each computer, linked by the serial#.

I would like to use a macro button on the form, to add some "default" software to the subform. How can this be done? I tried a macro, it adds a line to the subform table, but not the serial#, so it never links when viewed in the form.
 
Hi

At its most simple this could be done in code using an insert statement eg

DoCmd.RunSQL "INSERT ...etc"

But if you do not insert the SerialNo into the table on which thes ubform is based you will have the same problem as your macro

How are you keeping the lsit of default software?

In a Table I assume?

In which case an "INSERT INTO " statement may be more appropriate

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken,

This is what I am trying to do via query.

INSERT INTO Software [Software.App] = "Microsoft Office 2003***",[ Software.PC] = Forms!Computers2!Serialno;

Software is the table in my subform
App is the software name
PC is the serial number

My form is Computers2, and SerialNo is what I want transferred to Software.PC so it shows up in the subform.

When I try to save this query, it says syntax error.
 
Ken,

I also tried this, and it says the number of query values and destination values are not the same.

INSERT INTO Software (Software.App,Software.PC)
VALUES (["Microsoft Office 2003***"]),( [Forms!Computers2!Serialno])
 
Ken,

This one worked:
INSERT INTO Software ( App, PC )
VALUES ("Microsoft Office 2003***", Forms!Computers2!Serialno);

How can I add multiple rows at a time?
I tried to copy/paste the commands but the query only works from one INSERT INTO statement.
 
Hi

INSERT INTO Software (Software.App,Software.PC)
VALUES (["Microsoft Office 2003***"]),( [Forms!Computers2!Serialno])

is nearer the correct syntax

try

"INSERT INTO Software (Software.App,Software.PC)
VALUES ('Microsoft Office 2003***'),('" & [Forms!Computers2!Serialno] & "');"

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top