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:
  1. Sub update(frm As Form)
  2.     On Error Resume Next
  3.    
  4.     Dim Ctl As Control
  5.     Dim Obj As Object
  6.     Dim CtlType As String
  7.     Dim MeRecord As String
  8.     Dim MeValue As String
  9.  
  10.     'set the controls' values to the DB using the
  11.     'Tag property to locate the PK
  12.  
  13.     For Each Ctl In frm.Controls
  14.        
  15.         If CtlType = "Label" Then
  16.             'do nothing
  17.         ElseIf CtlType = "TextBox" Then
  18.             MeRecord = Ctl.Tag
  19.             MeValue = Ctl.Text
  20.         ElseIf CtlType = "ComboBox" Then
  21.             MeRecord = Ctl.Tag
  22.             MeValue = Ctl.Value
  23.         Else
  24.             'Wonder what the hell is going on... Buttons
  25.         End If
  26.         'Take to values and now add them to the data base
  27.         'Um find record where PK=MeRecord Set Value = MeValue
  28.     Next
  29. 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