O
OldManRiver via AccessMonster.com
All,
Have a form with over 189 controls on it and trying to automate the save.
I currently use the following script to init the fields:
So wanting to write something based on temp table containing 2 column
Frm_Fld_Name, and Tbl_Fld_Name for assignment of form field to table field;
maybe looking like this:
So I do not have to run documenter and cut/paste all vars into the
save subroutine.
Is my idea solid and what are the pit falls?
OMR
Have a form with over 189 controls on it and trying to automate the save.
I currently use the following script to init the fields:
Code:
On Error GoTo Err_Msg
For Each ctl In Targetform.Controls
' 100 = Label, 106 = CheckBox, 109 = TextBox, 111 = ComboBox
Select Case ctl.ControlType
Case 106
If ctl.Visible = True Then ctl = Null
Case 111
If ctl.Visible = True Then ctl = Null
Case 109
If ctl.Visible = True Then ctl = ""
End Select
Next
Exit Sub
Err_Msg:
MsgBox ctl.Name & " => " & "Error => " & Err.Number & " => " & Err.
Description
Frm_Fld_Name, and Tbl_Fld_Name for assignment of form field to table field;
maybe looking like this:
Code:
Dim dbs As DAO.Database, WsP As DAO.Workspace, RsS As DAO.Recordset
SrchNo = Targetform![cboxPSH]
RECnum = DLookup("cad_rno", "tblCADdetail", "[cad_pjx]=" & SrchNo)
WhrStr = "WHERE (([cad_pjx]=" & SrchNo & ") AND ([cad_rno]='" & RECnum &
"'))"
CSTstr = "SELECT * FROM tblCADdetail " & WhrStr & " ORDER BY cad_cds;"
Set Wspace = DBEngine.Workspaces(0)
Set dbs = CurrentDb
Set RsS = dbs.OpenRecordset(CSTstr, dbReadOnly)
With RsS
If .RecordCount > 0 Then
.MoveFirst
.Edit
Else
.AddNew
End If
On Error GoTo Err_Msg
For Each ctl In Targetform.Controls
' 100 = Label, 106 = CheckBox, 109 = TextBox, 111 = ComboBox
Select Case ctl.ControlType
Case 106, 109, 111
TF_Name = DLookup("Tbl_Fld_Name","TF_Var_Def","[Frm_Fld_Name]
=" & ctl.Name)
Eval (![TF_Name] = ctl)
End Select
Next
.Update
.Close
End With
Exit Sub
Err_Msg:
MsgBox ctl.Name & " => " & "Error => " & Err.Number & " => " & Err.
Description
save subroutine.
Is my idea solid and what are the pit falls?
OMR