J
Joshua Powell
I have what, were it not for this incredibly frustrating error, is a
pretty much completed database. The form in question causes me much
headache whenever I close it while in a new record. I describe just
about everything I think could be important to understanding this
problem below.
The form is called frmGroups and is based off of tblGroups. tblGroups
has these fields -
lngGroupID(Primary/Autonumber), lngAgentID, strGroupName, hypWebsite,
hypEmail
frmGroups has two subforms-
subfrmGroupDetails is based off of tblGroupDetails and is made up of
lngGroupID(Primary/Long Int) and a few other fields which are probably
of no consequence. tblGroups and tblGroupDetails are inner joined on
Group ID without Referential Integrity. frmGroup and
subfrmGroupDetails link child/master on GroupID
subfrmAgents is based off of qryLIST_Agents the SQL of which is below:
SELECT tblGroups.lngGroupID, tblAgents.lngAgentID,
tblAgencies.lngAgencyID, tblIndividuals!strFirstName & " " &
tblIndividuals!strLastName AS strAgentName, tblAgencies.strAgencyName,
tblIndividuals.lngIndividualID
FROM (tblAgencies INNER JOIN (tblIndividuals INNER JOIN tblAgents ON
tblIndividuals.lngIndividualID = tblAgents.lngIndividualID) ON
tblAgencies.lngAgencyID = tblAgents.lngAgencyID) INNER JOIN tblGroups
ON tblAgents.lngAgentID = tblGroups.lngAgentID
WHERE (((tblGroups.lngGroupID)=[Forms]![frmGroups]![txtGroupID]))
ORDER BY tblIndividuals!strFirstName & " " &
tblIndividuals!strLastName;
The error I get is "Microsoft Access has encountered a problem and
needs to close. We are sorry for the inconvenience. The information
you were woking on might be lost. Microsoft Access can try to compact
and repair your open database." Then gives me the option to compact
and repair and reopen, and tells me there is an error report it wants
to send to Microsoft.
There are two ways that I've run into this message. Both times they
occur while I am in a new record, which I get to by pressing cmdNew.
If I press cmdClose while in a new record I get an error. I tried to
sidestep this by saving the record and having cmdClose send me back to
the first record before closing but that still causes a problem. In
fact, If I use cmdNext to scroll through the records until I get to
the last one, and pressing it one more time brings me to a new record,
then scroll back again - closing the record still generates this
problem, but if I never go into new record mode, everything is peachy
keen.
I encountered this type of error earlier on in designing when I was
leaving DAO Recordsets open, but I have gone through and fixed all of
those. This error occurs on three different computers, three totally
different locations, so I don't think it's a software issue. I've
exported everything into new .mdb's one piece at a time trying to
isolate what's causing the error and still no luck. All my code is
compiled without error, I've tested everything I could think and I
don't get errors anywhere else, my database is compacted (by my choice
and by being forced to by this error!). I have two other forms that I
close while in a new record using the exact same method and no
problem!
So I attach the relevant Visual Basic code and hopefully someone can
help me out! The first sub is called by Form_Load and the
"Error_Handler" is the same and present for all of my procedures, I
don't include them for space's sake.
Private Sub ResetForm()
On Error GoTo Error_Handler
Me!lstMembers.RowSource = "qryLIST_GroupMembers"
Me.txtIndividualID.Value = 0
Me!lstPhones.RowSource = "qryLIST_GroupMemberPhones"
Me!lstEmails.RowSource = "qryList_GroupMemberEmails"
Form_subfrmAgents!lstAgencyPhones.RowSource =
"qryLIST_AgencyPhones"
Form_subfrmAgents!lstAgentEmails.RowSource = "qryLIST_AgentEmails"
Form_subfrmAgents!lstAgentPhones.RowSource = "qryLIST_AgentPhones"
Form_subfrmGroupDetails!lstPerformerGenres.RowSource =
"qryLIST_GroupGenres"
Me.TabCtl0.Enabled = True
If (IsNull(Me.txtAgentID)) Then
Me!cmdDeleteBookingAgent.Enabled = False
Else
Me!cmdDeleteBookingAgent.Enabled = True
End If
Error_Exit:
Exit Sub
Error_Handler:
MsgBox "Please take note of the following information:" & vbCrLf &
vbCrLf & _
"Number: " & Err.Number & vbCrLf & _
"Source: " & Me.Name & ".ResetForm." & Err.Source & vbCrLf
& _
"Description: " & Err.Description, _
vbCritical + vbOKOnly, _
"ERROR"
Resume Error_Exit
End Sub
Private Sub cmdNew_Click()
DoCmd.GoToRecord , , acNewRec
ResetForm
Me.txtGroupName.SetFocus
Me.cmdAddBookingAgent.Enabled = False 'Without which subfrmAgents
is usless
Me.TabCtl0.Enabled = False 'This Tab is where subfrmGroupDetails
is
Me.cmdDelete.Enabled = False
Me.cmdNew.Enabled = False
Me.cmdNext.Enabled = False
Me.cmdPrevious.Enabled = False
Forms!frmStart.cmdClose.Enabled = False 'this is a switchboard
that is always visible
Private Sub cmdCancel_Click()
Dim intResult As Integer
If Me.NewRecord Then
intResult = MsgBox("do you want to save this record?",
vbYesNo, "Save?")
If intResult = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
ElseIf intResult = vbNo Then
DoCmd.GoToRecord , , acFirst
End If
End If
Forms!frmStart.cmdClose.Enabled = True
DoCmd.Close acForm, Me.Name
Forms!frmStart.cmdGroups.SetFocus
End Sub
pretty much completed database. The form in question causes me much
headache whenever I close it while in a new record. I describe just
about everything I think could be important to understanding this
problem below.
The form is called frmGroups and is based off of tblGroups. tblGroups
has these fields -
lngGroupID(Primary/Autonumber), lngAgentID, strGroupName, hypWebsite,
hypEmail
frmGroups has two subforms-
subfrmGroupDetails is based off of tblGroupDetails and is made up of
lngGroupID(Primary/Long Int) and a few other fields which are probably
of no consequence. tblGroups and tblGroupDetails are inner joined on
Group ID without Referential Integrity. frmGroup and
subfrmGroupDetails link child/master on GroupID
subfrmAgents is based off of qryLIST_Agents the SQL of which is below:
SELECT tblGroups.lngGroupID, tblAgents.lngAgentID,
tblAgencies.lngAgencyID, tblIndividuals!strFirstName & " " &
tblIndividuals!strLastName AS strAgentName, tblAgencies.strAgencyName,
tblIndividuals.lngIndividualID
FROM (tblAgencies INNER JOIN (tblIndividuals INNER JOIN tblAgents ON
tblIndividuals.lngIndividualID = tblAgents.lngIndividualID) ON
tblAgencies.lngAgencyID = tblAgents.lngAgencyID) INNER JOIN tblGroups
ON tblAgents.lngAgentID = tblGroups.lngAgentID
WHERE (((tblGroups.lngGroupID)=[Forms]![frmGroups]![txtGroupID]))
ORDER BY tblIndividuals!strFirstName & " " &
tblIndividuals!strLastName;
The error I get is "Microsoft Access has encountered a problem and
needs to close. We are sorry for the inconvenience. The information
you were woking on might be lost. Microsoft Access can try to compact
and repair your open database." Then gives me the option to compact
and repair and reopen, and tells me there is an error report it wants
to send to Microsoft.
There are two ways that I've run into this message. Both times they
occur while I am in a new record, which I get to by pressing cmdNew.
If I press cmdClose while in a new record I get an error. I tried to
sidestep this by saving the record and having cmdClose send me back to
the first record before closing but that still causes a problem. In
fact, If I use cmdNext to scroll through the records until I get to
the last one, and pressing it one more time brings me to a new record,
then scroll back again - closing the record still generates this
problem, but if I never go into new record mode, everything is peachy
keen.
I encountered this type of error earlier on in designing when I was
leaving DAO Recordsets open, but I have gone through and fixed all of
those. This error occurs on three different computers, three totally
different locations, so I don't think it's a software issue. I've
exported everything into new .mdb's one piece at a time trying to
isolate what's causing the error and still no luck. All my code is
compiled without error, I've tested everything I could think and I
don't get errors anywhere else, my database is compacted (by my choice
and by being forced to by this error!). I have two other forms that I
close while in a new record using the exact same method and no
problem!
So I attach the relevant Visual Basic code and hopefully someone can
help me out! The first sub is called by Form_Load and the
"Error_Handler" is the same and present for all of my procedures, I
don't include them for space's sake.
Private Sub ResetForm()
On Error GoTo Error_Handler
Me!lstMembers.RowSource = "qryLIST_GroupMembers"
Me.txtIndividualID.Value = 0
Me!lstPhones.RowSource = "qryLIST_GroupMemberPhones"
Me!lstEmails.RowSource = "qryList_GroupMemberEmails"
Form_subfrmAgents!lstAgencyPhones.RowSource =
"qryLIST_AgencyPhones"
Form_subfrmAgents!lstAgentEmails.RowSource = "qryLIST_AgentEmails"
Form_subfrmAgents!lstAgentPhones.RowSource = "qryLIST_AgentPhones"
Form_subfrmGroupDetails!lstPerformerGenres.RowSource =
"qryLIST_GroupGenres"
Me.TabCtl0.Enabled = True
If (IsNull(Me.txtAgentID)) Then
Me!cmdDeleteBookingAgent.Enabled = False
Else
Me!cmdDeleteBookingAgent.Enabled = True
End If
Error_Exit:
Exit Sub
Error_Handler:
MsgBox "Please take note of the following information:" & vbCrLf &
vbCrLf & _
"Number: " & Err.Number & vbCrLf & _
"Source: " & Me.Name & ".ResetForm." & Err.Source & vbCrLf
& _
"Description: " & Err.Description, _
vbCritical + vbOKOnly, _
"ERROR"
Resume Error_Exit
End Sub
Private Sub cmdNew_Click()
DoCmd.GoToRecord , , acNewRec
ResetForm
Me.txtGroupName.SetFocus
Me.cmdAddBookingAgent.Enabled = False 'Without which subfrmAgents
is usless
Me.TabCtl0.Enabled = False 'This Tab is where subfrmGroupDetails
is
Me.cmdDelete.Enabled = False
Me.cmdNew.Enabled = False
Me.cmdNext.Enabled = False
Me.cmdPrevious.Enabled = False
Forms!frmStart.cmdClose.Enabled = False 'this is a switchboard
that is always visible
Private Sub cmdCancel_Click()
Dim intResult As Integer
If Me.NewRecord Then
intResult = MsgBox("do you want to save this record?",
vbYesNo, "Save?")
If intResult = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
ElseIf intResult = vbNo Then
DoCmd.GoToRecord , , acFirst
End If
End If
Forms!frmStart.cmdClose.Enabled = True
DoCmd.Close acForm, Me.Name
Forms!frmStart.cmdGroups.SetFocus
End Sub