I am using some labels as controls on a form:
There are similar procedures for label 2 + 3 ...
I know it looks a bit confusing but it actually works (for the most part) and I like the html look and feel of the labels as opposed to buttons.
My problem is that the labels only work the first time I click one of them.
I can click label1 as the first action after I open the form - and it works.
However, if I click some of the other labels a couple of times to navigate around and thereby change the subforms and what not, and then hit label1, all of a sudden doesn't work anymore!?! I don't even get the Msgbox "No action defined" ... Just a subform with no records at all ...
Code:
Private Sub Label1_Click()
If Form_frmSubformFA.Label1.Caption = "Edit" And Form_frmSubformFA![SubFA].SourceObject = "frmFALog" Then
Form_frmSubformFA![SubFA].SourceObject = "frmFALogEdit"
Form_frmSubformFA.Label1.Caption = "Save"
Form_frmSubformFA.Label2.Caption = "Undo"
Form_frmSubformFA.Label3.Caption = "Delete records"
Form_frmSubformFA.Repaint
ElseIf Form_frmSubformFA.Label1.Caption = "Edit" And Form_frmSubformFA![SubFA].SourceObject = "frmFALogDetail" Then
Form_frmSubformFA![SubFA].SourceObject = "frmFALogDetailEdit"
Form_frmSubformFA.Label1.Caption = "Save"
Form_frmSubformFA.Label2.Caption = "Undo"
Form_frmSubformFA.Label3.Caption = "Delete records"
Form_frmSubformFA.Repaint
ElseIf Form_frmSubformFA.Label1.Caption = "Save" And Form_frmSubformFA![SubFA].SourceObject = "frmFALogEdit" Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_frmSubformFA![SubFA].SourceObject = "frmFALog"
Form_frmSubformFA.Label1.Caption = "Edit"
Form_frmSubformFA.Label2.Caption = "Add new entry"
Form_frmSubformFA.Label3.Caption = "Detailed view"
Form_frmSubformFA.Repaint
ElseIf Form_frmSubformFA.Label1.Caption = "Save" And Form_frmSubformFA![SubFA].SourceObject = "frmFALogDetailEdit" Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_frmSubformFA![SubFA].SourceObject = "frmFALogDetail"
Form_frmSubformFA.Label1.Caption = "Edit"
Form_frmSubformFA.Label2.Caption = "Add new entry"
Form_frmSubformFA.Label3.Caption = "Hide Details"
Form_frmSubformFA.Repaint
ElseIf Form_frmSubformFA.Label1.Caption = "Save new entry" And Form_frmSubformFA![SubFA].SourceObject = "frmAddFA" Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_frmSubformFA![SubFA].SourceObject = "frmFALog"
Form_frmSubformFA.Label1.Caption = "Edit"
Form_frmSubformFA.Label2.Caption = "Add new entry"
Form_frmSubformFA.Label3.Visible = True
Form_frmSubformFA.Box3.Visible = True
Form_frmSubformFA.Repaint
ElseIf Form_frmSubformFA.Label1.Caption = "Delete selected" And Form_frmSubformFA![SubFA].SourceObject = "frmFADelete" Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Form_frmSubformFA![SubFA].SourceObject = "frmFALog"
Form_frmSubformFA.Label1.Caption = "Edit"
Form_frmSubformFA.Label2.Caption = "Add new entry"
Form_frmSubformFA.Label3.Caption = "Detailed view"
Form_frmSubformFA.Label3.Visible = True
Form_frmSubformFA.Box3.Visible = True
Form_frmSubformFA.Repaint
Else
MsgBox "No action defined"
End If
End Sub
There are similar procedures for label 2 + 3 ...
I know it looks a bit confusing but it actually works (for the most part) and I like the html look and feel of the labels as opposed to buttons.
My problem is that the labels only work the first time I click one of them.
I can click label1 as the first action after I open the form - and it works.
However, if I click some of the other labels a couple of times to navigate around and thereby change the subforms and what not, and then hit label1, all of a sudden doesn't work anymore!?! I don't even get the Msgbox "No action defined" ... Just a subform with no records at all ...