how to update two table

mr.cool

New member
Local time
Today, 08:58
Joined
Sep 9, 2008
Messages
4
hello

how I can update two table
I have
table 1 -tabman
table 2 -subtable
and I'm using this code for this

Code:
Private Sub updt_Click()
If IsNull(fnumber) Then
   If MsgBox("?", vbCritical + vbOKOnly, "?") = vbOK Then
   End If
  fnumber.SetFocus
   Exit Sub
End If
If DLookup("no_itm", "tabman", "no_itm ='" & fnumber & "'") = fnumber Then
   DoCmd.RunSQL ("UpDate subtable  Set nameOrder = forder ")
     DoCmd.RunSQL ("UpDate tabman  Set name_q = fnume , namePice = fwohd ,loc1 = floca , total = ftotal ,date_ins = fdateisd  Where tabman.no_itm =  [fnumber] ")  
Else
   DoCmd.RunSQL ("Insert Into subtable (nameOrder ) Values (forder) ;")
   DoCmd.RunSQL ("Insert Into tabman (no_itm,name_q,namePice,loc1,total,date_ins) Values ( fnumber,fnume,fwohd,floca,ftotal,fdateisd) ;")
End If
Call Cls_Click
End Sub

the table 1 -tabman
update successful
but table 2-subtable not update
what I can do for this
 
First off there is no such thing as a sub table. You can have a sub form but not a sub table. I am assuming that the main form and the sub form have two different tables as their recordsources. No offense but your code is a little hard to follow can you tell us what you are trying to do, not just update two tables. With a clearer description of your intended actions we can help you with the update query code. Maybe it's just me but I don't ever use dlookup.
 
The update of subtable has no where clause to identify the record to be updated, and it has not been retrieved by a dlookup to allow for an update. The inserts should be fine.
 
here is what am i trying to creat:

I have two tables,one called tabman and the other one called subtable. the second table is kustcalled subtable, it is actually not a subtable. THe problem iam facing is that one i update table "tabman" it would be updated find. However, updting the second table "subtable" is impossible, i canot save the updates on the second table.

below is a link to the program for modification.

http://www.2shared.com/file/3907596/9eb2905c/stork.html

Your assistance is highly approciated.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom