I have posted a similar question to this before so it's possible that given time I will solve this myself. But the help would be real good all the same.
I am working on a database project where there is a table of "global" values. It has two fields PK and Value both text. PK is the Primary Key (Duh).
The form is designed from unbound controls (mainly textboxes and comboboxes) one for each record. I have set the tag value to hold the PK of the destination record and the control clearly will hold the value for the Value field.
The plan is to have a module that contains a function of sub that will cycle through the controls on the form and add the values to the correct record.
Not knowing what to do I have started to plan out said Sub with the result that I have pritty much of the code fairly well written. However I am fairly new to the whole dealing with objects thing and would apriciate some feed back on my code (untested) and some clues on how to do the update records.
VB Code:
Sub update(frm As Form) On Error Resume Next Dim Ctl As Control Dim Obj As Object Dim CtlType As String Dim MeRecord As String Dim MeValue As String 'set the controls' values to the DB using the 'Tag property to locate the PK For Each Ctl In frm.Controls If CtlType = "Label" Then 'do nothing ElseIf CtlType = "TextBox" Then MeRecord = Ctl.Tag MeValue = Ctl.Text ElseIf CtlType = "ComboBox" Then MeRecord = Ctl.Tag MeValue = Ctl.Value Else 'Wonder what the hell is going on... Buttons End If 'Take to values and now add them to the data base 'Um find record where PK=MeRecord Set Value = MeValue Next End Sub
if you really want to know the same topic post in this forum was called: Access Module Code: rst.movenext I assume... but that aside I'm a bit stuck today... the answers in other thread might help a bit but it deals with Access to Word more'n anything else.
Thanks in advance





Reply With Quote