B
BonnieW via AccessMonster.com
I'm modifying some old code in some old forms to make them work (hopefully).
We have a form that had three subforms on them, all combo boxes: one is not
being used, the other is working as intended, and the third I'm having a
problem with. The third subform, Activity, would default to inputting the
first record on the list (odd coincidence, but completely unrelated to my
first post today). It's pulling these records from a small sql query which
apparently works just dandy. Looking at this subform, I could see no reason
why it was a subform and not a combo box, so to try to simplify things I made
it a combo box. Now, there's a bit of code in the form which tests to see if
the values of various fields are null (before entering the record... it
doesn't actually work, but that's another gripe, I think); I cannot get this
to recognize the combo box as not null. I'm not sure if I'm referencing it
correctly; furthermore, it's not being entered into the table with the other
data- so it probably really *is* null, despite it showing up quite nicely on
the form.
Here is the trainwreck of code for the form (if you're sensitive, shield your
eyes- I know no VBA and even I realize this has got to be bad):
Option Compare Database
Private Sub Child32_Enter()
End Sub
Private Sub Combo24_Change()
Refresh
ManageUnitID = Text34.Value
End Sub
Private Sub Command45_Click()
Rem Set up variables to use in this subroutine
seqNum_MasterRec = ConsEffortID
savedNatAreaID = NatAreaID.Value
savedActivity = Activity.Value
Rem NOTE - Management Unit is not yet active for volunteers
Rem savedMgtUnit = ManageUnitID.Value
Rem savedMgtUnitName = Combo24.Value
Rem Make sure that required fields are present
If IsNull(Activity.Value) Then
MsgBox "Missing Required Field - Activity!"
Exit Sub
End If
If IsNull(EffortDate.Value) Then
MsgBox "Missing Required Field - Effort Date!"
Exit Sub
End If
If IsNull(Hours.Value) Then
MsgBox "Missing Required Field - Hours!"
Exit Sub
End If
If IsNull(PeopleType.Value) Then
MsgBox "Missing Required Field - PeopleType!"
Exit Sub
Rem Else
Rem Refresh
Rem DoCmd.Save
Rem DoCmd.GoToRecord , , acNext, 1
Rem Refresh
End If
End_Sub:
PeopleType.Value = Combo0
savedConsEffortID = ConsEffortID
NatAreaID.Value = savedNatAreaID
Activity.Value = savedActivity
Rem NOTE - Management Unit is not yet active for volunteers
Rem ManageUnitID.Value = savedMgtUnit
Rem Combo24.Value = savedMgtUnitName
Rem DoCmd.GoToControl "Combo24"
DoCmd.GoToRecord , , acNext
Rem Look for special circumstances that require subforms for data entry
If savedActivity = "Trail Work" Then
DoCmd.OpenForm "frmTrailWorkEntry", , , , acFormAdd
End If
If savedActivity = "Invasives Control" Then
DoCmd.OpenForm "frmInvasivesControlCrewNew", , , , acFormAdd
End If
If savedActivity = "Revegetation" Then
DoCmd.OpenForm "frmRevegetationNew", , , , acFormAdd
End If
End Sub
' Private Sub Form_AfterUpdate()
' MsgBox "Saved."
' End Sub
Private Sub Command62_Click()
DoCmd.OpenForm "tablePeople", , , , acFormEdit
PeopleID.Value = [Forms]![tablePeople]![PeopleID]
Text58.Value = [Forms]![tablePeople]![FirstName]
Text60.Value = [Forms]![tablePeople]![LastName]
Refresh
End Sub
Private Sub Form_GotFocus()
Requery
PeopleID.Value = [Forms]![tablePeople]![PeopleID]
Text58.Value = [Forms]![tablePeople]![FirstName]
Text60.Value = [Forms]![tablePeople]![LastName]
Activity.Value = [svbFrmtbl1Activity].Form![ActivityName]
PeopleType.Value = [frmPeopleType].Form![PeopleType]
End Sub
'Private Sub frmPeopleType_Exit(Cancel As Integer)
' PeopleType.Value = [frmPeopleType].Form![PeopleType]
' Refresh
' DoCmd.GoToControl "Notes"
'End Sub
Private Sub svbFrmtbl1Activity_Exit(Cancel As Integer)
Activity.Value = [svbFrmtbl1Activity].Form![ActivityName]
Refresh
DoCmd.GoToControl "EffortDate"
End Sub
Private Sub Text34_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Toggle26_Click()
Me.Undo
DoCmd.Close , , acSaveNo
End Sub
Private Sub Command54_Click()
On Error GoTo Err_Command54_Click
DoCmd.Close
DoCmd.Close , tablePeople
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub
We have a form that had three subforms on them, all combo boxes: one is not
being used, the other is working as intended, and the third I'm having a
problem with. The third subform, Activity, would default to inputting the
first record on the list (odd coincidence, but completely unrelated to my
first post today). It's pulling these records from a small sql query which
apparently works just dandy. Looking at this subform, I could see no reason
why it was a subform and not a combo box, so to try to simplify things I made
it a combo box. Now, there's a bit of code in the form which tests to see if
the values of various fields are null (before entering the record... it
doesn't actually work, but that's another gripe, I think); I cannot get this
to recognize the combo box as not null. I'm not sure if I'm referencing it
correctly; furthermore, it's not being entered into the table with the other
data- so it probably really *is* null, despite it showing up quite nicely on
the form.
Here is the trainwreck of code for the form (if you're sensitive, shield your
eyes- I know no VBA and even I realize this has got to be bad):
Option Compare Database
Private Sub Child32_Enter()
End Sub
Private Sub Combo24_Change()
Refresh
ManageUnitID = Text34.Value
End Sub
Private Sub Command45_Click()
Rem Set up variables to use in this subroutine
seqNum_MasterRec = ConsEffortID
savedNatAreaID = NatAreaID.Value
savedActivity = Activity.Value
Rem NOTE - Management Unit is not yet active for volunteers
Rem savedMgtUnit = ManageUnitID.Value
Rem savedMgtUnitName = Combo24.Value
Rem Make sure that required fields are present
If IsNull(Activity.Value) Then
MsgBox "Missing Required Field - Activity!"
Exit Sub
End If
If IsNull(EffortDate.Value) Then
MsgBox "Missing Required Field - Effort Date!"
Exit Sub
End If
If IsNull(Hours.Value) Then
MsgBox "Missing Required Field - Hours!"
Exit Sub
End If
If IsNull(PeopleType.Value) Then
MsgBox "Missing Required Field - PeopleType!"
Exit Sub
Rem Else
Rem Refresh
Rem DoCmd.Save
Rem DoCmd.GoToRecord , , acNext, 1
Rem Refresh
End If
End_Sub:
PeopleType.Value = Combo0
savedConsEffortID = ConsEffortID
NatAreaID.Value = savedNatAreaID
Activity.Value = savedActivity
Rem NOTE - Management Unit is not yet active for volunteers
Rem ManageUnitID.Value = savedMgtUnit
Rem Combo24.Value = savedMgtUnitName
Rem DoCmd.GoToControl "Combo24"
DoCmd.GoToRecord , , acNext
Rem Look for special circumstances that require subforms for data entry
If savedActivity = "Trail Work" Then
DoCmd.OpenForm "frmTrailWorkEntry", , , , acFormAdd
End If
If savedActivity = "Invasives Control" Then
DoCmd.OpenForm "frmInvasivesControlCrewNew", , , , acFormAdd
End If
If savedActivity = "Revegetation" Then
DoCmd.OpenForm "frmRevegetationNew", , , , acFormAdd
End If
End Sub
' Private Sub Form_AfterUpdate()
' MsgBox "Saved."
' End Sub
Private Sub Command62_Click()
DoCmd.OpenForm "tablePeople", , , , acFormEdit
PeopleID.Value = [Forms]![tablePeople]![PeopleID]
Text58.Value = [Forms]![tablePeople]![FirstName]
Text60.Value = [Forms]![tablePeople]![LastName]
Refresh
End Sub
Private Sub Form_GotFocus()
Requery
PeopleID.Value = [Forms]![tablePeople]![PeopleID]
Text58.Value = [Forms]![tablePeople]![FirstName]
Text60.Value = [Forms]![tablePeople]![LastName]
Activity.Value = [svbFrmtbl1Activity].Form![ActivityName]
PeopleType.Value = [frmPeopleType].Form![PeopleType]
End Sub
'Private Sub frmPeopleType_Exit(Cancel As Integer)
' PeopleType.Value = [frmPeopleType].Form![PeopleType]
' Refresh
' DoCmd.GoToControl "Notes"
'End Sub
Private Sub svbFrmtbl1Activity_Exit(Cancel As Integer)
Activity.Value = [svbFrmtbl1Activity].Form![ActivityName]
Refresh
DoCmd.GoToControl "EffortDate"
End Sub
Private Sub Text34_BeforeUpdate(Cancel As Integer)
End Sub
Private Sub Toggle26_Click()
Me.Undo
DoCmd.Close , , acSaveNo
End Sub
Private Sub Command54_Click()
On Error GoTo Err_Command54_Click
DoCmd.Close
DoCmd.Close , tablePeople
Exit_Command54_Click:
Exit Sub
Err_Command54_Click:
MsgBox Err.Description
Resume Exit_Command54_Click
End Sub