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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pick parameter from form and update record

Status
Not open for further replies.

jozino01

Technical User
Apr 25, 2003
257
CA
hi,

i have the following tables:
1) CUTS with fields CUTID, NUMBER
2) LOGS with fields CUTID, BOOM, VOLUME, TOTAL

i have one form fSELLOGS with Combo0 populated with CUTS.NUMBER and list box List4 populated with LOGS.BOOM, LOGS.VOLUME, LOGS.TOTAL

i have event procedure:
Private Sub List4_DblClick(Cancel As Integer)
DoCmd.OpenQuery "fqSELLOGS", acNormal, acEdit
End Sub

and query fqSELLOGS:
UPDATE LOGS SET LOGS.CUTID = (select [cutid] from [cuts] where [cuts].[number]=forms!fsellogs!combo0)
WHERE ((([LOGS].[BOOM])=[forms]![fSELLOGS]![list4]));

the idea is to update selected records in LOGS based on value picked from CUTS.

however, when trying to do it, the system gives me error message saying "operation must use an updateable query"

my query is an update query; any idea how to make it work, please?
 
Make sure you have primary keys set on your tables. If not it will not update.

Don't think and the solution will come.
 
primary keys are set. it might have something to do with passing right value from listbox (and selecting more than one row). i tried different ways and not sure what is the proper method to pick up and pass parameter from listbox(?)

UPDATE LOGS SET LOGS.CUTID = (select [cutid] from [cuts] where [cuts].[number]=forms!fsellogs!combo0.text)
WHERE ((([LOGS].[BOOM])=forms!fSELLOGS!list4.ItemSelected));
 
What are you using for your Primary keys?

Don't think and the solution will come.
 
Perhaps this ?
UPDATE LOGS
SET CUTID = DLookUp("cutid", "cuts", "[number]=[Forms]![fSELLOGS]![Combo0]")
WHERE BOOM = [Forms]![fSELLOGS]![List4];


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
now i got message "invalid attribute is sub or function
 
to PHV - oops, sorry, it's not working. it put null into selected cutid in logs, it doesn't insert cutid from cuts.
 
Code:
UPDATE LOGS
SET CUTID = DLookUp("cutid", "cuts", "[number]='" & [Forms]![fSELLOGS]![Combo0] & "'")
WHERE BOOM = [Forms]![fSELLOGS]![List4];

If number is defined as numeric in cuts then get rid of the single quotes.
The bound column of Combo0 must be the Number column.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
NUMBER in CUTS is text

CUTID NUMBER
1 INVENTORY 2006
2 JAG 6-1
3 LOG SALES
4 JAG 6-3
5 JAG 6-2
6 JAG 6-4
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top