Hi,
I have a small DB which is supposed to handle in-going and out-going entries for consumables, for this I have two tables [In] and [Out]. Here below is a brief table structure:
[In] table:
Id = Text (Auto increment field (not autonumber))
Document_In = Text
Part_No = Text
Items = Number
[Out] table:
Id = Text (automatically taken form the [Id] field [In] table)
Document_Out=Text
Part_No = Text
Items = Number
The main form [Register] holds all the data from the in table and has a subform with several fields from the [Out] table. Whenever a user modifies the data in the [Out] subform the [Id] is taken so’s that we can keep a relation between the two tables.
There are occasions when we need to update various entries in the [Out] table from this main screen.
One sloppy solution that has been used is to open a form called “Update” in AcIcon which is related to a query, update the said fields, goto next text record, and update again before closing the form:
n = DCount("Id", "MyQuery")
Check = True: Counter = 0
Do ' Outer loop.
DoCmd.OpenForm "Update", , , , , acIcon
Do While Counter < n
Counter = Counter + 1
Forms![Update]![Part_No]= Forms![In_Form]![Part_No]
Forms![Update]![Items]= Forms![In_Form]![Items]
If IsNull([Forms]![Update]![Id]) Then Check = False
DoCmd.GoToRecord , , acNext
If Counter = n Then
Check = False
Exit Do
End If
Loop
Loop Until Check = False
DoCmd.Close acForm, "Update"
I would really be grateful if someone could help me create a routine that can loop through and update the fields without having to go through the above sloppy process.
Thanks,
I have a small DB which is supposed to handle in-going and out-going entries for consumables, for this I have two tables [In] and [Out]. Here below is a brief table structure:
[In] table:
Id = Text (Auto increment field (not autonumber))
Document_In = Text
Part_No = Text
Items = Number
[Out] table:
Id = Text (automatically taken form the [Id] field [In] table)
Document_Out=Text
Part_No = Text
Items = Number
The main form [Register] holds all the data from the in table and has a subform with several fields from the [Out] table. Whenever a user modifies the data in the [Out] subform the [Id] is taken so’s that we can keep a relation between the two tables.
There are occasions when we need to update various entries in the [Out] table from this main screen.
One sloppy solution that has been used is to open a form called “Update” in AcIcon which is related to a query, update the said fields, goto next text record, and update again before closing the form:
n = DCount("Id", "MyQuery")
Check = True: Counter = 0
Do ' Outer loop.
DoCmd.OpenForm "Update", , , , , acIcon
Do While Counter < n
Counter = Counter + 1
Forms![Update]![Part_No]= Forms![In_Form]![Part_No]
Forms![Update]![Items]= Forms![In_Form]![Items]
If IsNull([Forms]![Update]![Id]) Then Check = False
DoCmd.GoToRecord , , acNext
If Counter = n Then
Check = False
Exit Do
End If
Loop
Loop Until Check = False
DoCmd.Close acForm, "Update"
I would really be grateful if someone could help me create a routine that can loop through and update the fields without having to go through the above sloppy process.
Thanks,