Tay
likes garlic
- Local time
- Today, 12:59
- Joined
- May 24, 2002
- Messages
- 269
I really hope someone out there can help.....
I have a database which holds information about the progress of schemes. I have a main form holding info common to all schemes, and then depending upon the type of scheme, a subform specific to that scheme type will appear.
I found some code on here today which is brilliant. It highlights each control when it has the focus, so makes users lives that bit easier.
The code works perfectly for all main forms, but as soon as I enter the subform via the main form , I get an error message saying
"Access can't find the form "whatever" referred to in a macro or vb code.
The form you referenced may be closed or may not exist in this database.
Access may have encountered a compile error in a vb module for the form."
If I just go to the subform, the code does what it is supposed to.
It would be really helpful if I could get this to work, especially as the subforms are the main place where information is entered.
Here is the code I am using.
Option Compare Database
Option Explicit
Public Function TextGotFocus(strFrmName As String, strCtrlName As String)
Dim frm As Form
Dim ctrl As Control
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = 13619151
Set frm = Nothing
End Function
Public Function TextLostFocus(strFrmName As String, strCtrlName As String)
Dim frm As Form
Dim ctrl As Control
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = vbWhite
Set frm = Nothing
End Function
Sub Formfiller(StrForm As String)
Dim dbs As Database
Dim frm As Form
Dim ctrl As Control
Set dbs = CurrentDb()
DoCmd.OpenForm StrForm, acDesign
Set frm = Forms(StrForm)
For Each ctrl In frm.Controls
If ctrl.ControlType = acTextBox Then
ctrl.OnGotFocus = "=TextGotFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
ctrl.OnLostFocus = "=TextLostFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
End If
Next ctrl
DoCmd.Close acForm, StrForm, acSaveYes
End Sub
In the debug window, I enter all the relevant forms names as
formfiller("frmwhatever").
Any ideas on what I should do?
TIA
I have a database which holds information about the progress of schemes. I have a main form holding info common to all schemes, and then depending upon the type of scheme, a subform specific to that scheme type will appear.
I found some code on here today which is brilliant. It highlights each control when it has the focus, so makes users lives that bit easier.
The code works perfectly for all main forms, but as soon as I enter the subform via the main form , I get an error message saying
"Access can't find the form "whatever" referred to in a macro or vb code.
The form you referenced may be closed or may not exist in this database.
Access may have encountered a compile error in a vb module for the form."
If I just go to the subform, the code does what it is supposed to.
It would be really helpful if I could get this to work, especially as the subforms are the main place where information is entered.
Here is the code I am using.
Option Compare Database
Option Explicit
Public Function TextGotFocus(strFrmName As String, strCtrlName As String)
Dim frm As Form
Dim ctrl As Control
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = 13619151
Set frm = Nothing
End Function
Public Function TextLostFocus(strFrmName As String, strCtrlName As String)
Dim frm As Form
Dim ctrl As Control
Set frm = Forms(strFrmName)
frm.Controls(strCtrlName).BackColor = vbWhite
Set frm = Nothing
End Function
Sub Formfiller(StrForm As String)
Dim dbs As Database
Dim frm As Form
Dim ctrl As Control
Set dbs = CurrentDb()
DoCmd.OpenForm StrForm, acDesign
Set frm = Forms(StrForm)
For Each ctrl In frm.Controls
If ctrl.ControlType = acTextBox Then
ctrl.OnGotFocus = "=TextGotFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
ctrl.OnLostFocus = "=TextLostFocus(""" & frm.Name & """,""" & ctrl.Name & """)"
End If
Next ctrl
DoCmd.Close acForm, StrForm, acSaveYes
End Sub
In the debug window, I enter all the relevant forms names as
formfiller("frmwhatever").
Any ideas on what I should do?
TIA
