B
Biz Enhancer
Hi,
I have a problem with updating a label on multiple forms.
The scenario is that on each form I have a non-visible label that has a
number for its caption value.
Each form has a different number. This label named "fmno" supplies error
logging as well as a user rights functions.
The problem is that when I import forms into a new application I wish to
update the fmno.caption value programmatically by creating a recordset and
opening, updating, and closing each form in the recordset. I can't open the
forms in a Normal view as the fmno.caption value is incorrect and prevents
the form from opening (security routine on Form.Open). I can't pull the value
through on form.open as this would substantially weaken the security aspect.
Therefore I am trying to do this via the Design view. Code as follows:
********Code Start************
Private Sub Command15_Click()
On Error GoTo Errtrp
Dim Erm As String, fm As String, MyDB As Database, rs As Recordset, e As
String, k As String, t As String
fm = Me.fmno.Caption
Erm = "F" & fm & "/C15cl"
Set MyDB = CurrentDb()
Set rs = MyDB.OpenRecordset("SELECT frmtbl.jid, frmtbl.title FROM frmtbl;")
While Not rs.EOF
e = rs.Fields(1)
k = "" & rs.Fields(0) & ""
t = "" & e & ""
DoCmd.OpenForm e, acDesign, , , acFormEdit, acWindowNormal
Forms(t)(fmno).Caption = k
DoCmd.Close acForm, e, acSaveYes
rs.MoveNext
Wend
Exittrp:
Exit Sub
Errtrp:
Call faulttrp(Erm, Err.Number, Err.Description)
Resume Exittrp
End Sub
****Code End**********
Running this I get an error 438 "Object doesn't support this property or
method"
Any ideas on how to get around the problem?
Appreciate any help.
Thanks,
Nick.
I have a problem with updating a label on multiple forms.
The scenario is that on each form I have a non-visible label that has a
number for its caption value.
Each form has a different number. This label named "fmno" supplies error
logging as well as a user rights functions.
The problem is that when I import forms into a new application I wish to
update the fmno.caption value programmatically by creating a recordset and
opening, updating, and closing each form in the recordset. I can't open the
forms in a Normal view as the fmno.caption value is incorrect and prevents
the form from opening (security routine on Form.Open). I can't pull the value
through on form.open as this would substantially weaken the security aspect.
Therefore I am trying to do this via the Design view. Code as follows:
********Code Start************
Private Sub Command15_Click()
On Error GoTo Errtrp
Dim Erm As String, fm As String, MyDB As Database, rs As Recordset, e As
String, k As String, t As String
fm = Me.fmno.Caption
Erm = "F" & fm & "/C15cl"
Set MyDB = CurrentDb()
Set rs = MyDB.OpenRecordset("SELECT frmtbl.jid, frmtbl.title FROM frmtbl;")
While Not rs.EOF
e = rs.Fields(1)
k = "" & rs.Fields(0) & ""
t = "" & e & ""
DoCmd.OpenForm e, acDesign, , , acFormEdit, acWindowNormal
Forms(t)(fmno).Caption = k
DoCmd.Close acForm, e, acSaveYes
rs.MoveNext
Wend
Exittrp:
Exit Sub
Errtrp:
Call faulttrp(Erm, Err.Number, Err.Description)
Resume Exittrp
End Sub
****Code End**********
Running this I get an error 438 "Object doesn't support this property or
method"
Any ideas on how to get around the problem?
Appreciate any help.
Thanks,
Nick.