M
Michael Walsh
Sorry to post about this issue again, but I've gotten no
response as of yet and I'm guessing it has to do with bad
subjects.
I have a main form and a pop-up form. The pop-up form is
called by 3 different buttons on the main form using the
on-click event. The pop-up form is the summary section
for the main form and there are 3 different summaries, 1
for each button. Each button filters the form on a record
linking this pop-up to the main form as well as some hard
code linking the pop-up to the appropriate section (1, 2,
or 3).
The problem is this: the codes works for existing data,
but I cannot figure out how to make it create new data.
The current code only filters existing data and when there
is none, the hard code for the SectionID fails and the
form returns a SectionID of 0. The MainID works because
I'm able to set the default value of the pop-up form to
the corrsponding value on the main form. I'm unable to do
this with sections since they rely on a user choosing the
appropriate button.
So the question is what would the code look like if it
were to include a check for exisitng data in the
underlying table of the pop-up form (which is different
than the underlying table of the main form) and how would
I set default values in the on-click subroutine if there
were no data yet. Currently, the command button on-click
routine looks like this...
Private Sub ClinSummaryButton_Click()
On Error GoTo Err_ClinSummaryButton_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSummary"
stLinkCriteria = "[SiteVisitID]=" & Me![SiteVisitID]
& " and [SectionID]=1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ClinSummaryButton_Click:
Exit Sub
Err_ClinSummaryButton_Click:
MsgBox Err.Description
Resume Exit_ClinSummaryButton_Click
End Sub
response as of yet and I'm guessing it has to do with bad
subjects.
I have a main form and a pop-up form. The pop-up form is
called by 3 different buttons on the main form using the
on-click event. The pop-up form is the summary section
for the main form and there are 3 different summaries, 1
for each button. Each button filters the form on a record
linking this pop-up to the main form as well as some hard
code linking the pop-up to the appropriate section (1, 2,
or 3).
The problem is this: the codes works for existing data,
but I cannot figure out how to make it create new data.
The current code only filters existing data and when there
is none, the hard code for the SectionID fails and the
form returns a SectionID of 0. The MainID works because
I'm able to set the default value of the pop-up form to
the corrsponding value on the main form. I'm unable to do
this with sections since they rely on a user choosing the
appropriate button.
So the question is what would the code look like if it
were to include a check for exisitng data in the
underlying table of the pop-up form (which is different
than the underlying table of the main form) and how would
I set default values in the on-click subroutine if there
were no data yet. Currently, the command button on-click
routine looks like this...
Private Sub ClinSummaryButton_Click()
On Error GoTo Err_ClinSummaryButton_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmSummary"
stLinkCriteria = "[SiteVisitID]=" & Me![SiteVisitID]
& " and [SectionID]=1"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_ClinSummaryButton_Click:
Exit Sub
Err_ClinSummaryButton_Click:
MsgBox Err.Description
Resume Exit_ClinSummaryButton_Click
End Sub