C
Cathleen
I am trying to use a command button on a subform (SecchiEntryParam_sub) of
the form named Secchi_Entry to open a second form (WeatherCond), which
contains the subform WeatherCond_sub and go to the corresponding record. This
seems overly complicated, but I cannot find a way around it. Each
form/subform’s record source is a different table. The purpose is to allow a
user who is entering lake clarity data to pull up the form/subform to enter
corresponding data on weather conditions.
I need to link on two criteria, but one is in the main form and one is in
the subform:
First, I need to link the field [event_id] on the SecchiEntryParam_sub
subform to [WeatherCondEvent_event_id] on the WeatherCond form (these are
numeric fields). This step appears to be working o.k.
However, I also need to link the field [sample_type_secchi] on the
SecchiEntryParam_sub subform to [sample_type_weathercond] on the
WeatherCond_sub subform (these are text fields). I’ve made many attempts at
this but always get some sort of error message.
In the On Click Event of the command button, I have:
Private Sub OpenWeatherCond_Click()
On Error GoTo Err_OpenWeatherCond_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "WeatherCond"
stLinkCriteria = "[WeatherCondEvent_event_id]= " & Me![event_id] & "And"
& "Forms![WeatherCond]![WeatherCond_sub].Form![sample_type_weathercond]='" &
Me![sample_type_secchi] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_OpenWeatherCond_Click:
Exit Sub
Err_OpenWeatherCond_Click:
MsgBox Err.Description
Resume Exit_OpenWeatherCond_Click
End Sub
I haven’t been able to find any other examples of someone linking on one
field in the main form and a second in a subform, so I’m hoping this can be
accomplished somehow. Could someone please check out my code and see what I
am doing wrong?
Thank you!
the form named Secchi_Entry to open a second form (WeatherCond), which
contains the subform WeatherCond_sub and go to the corresponding record. This
seems overly complicated, but I cannot find a way around it. Each
form/subform’s record source is a different table. The purpose is to allow a
user who is entering lake clarity data to pull up the form/subform to enter
corresponding data on weather conditions.
I need to link on two criteria, but one is in the main form and one is in
the subform:
First, I need to link the field [event_id] on the SecchiEntryParam_sub
subform to [WeatherCondEvent_event_id] on the WeatherCond form (these are
numeric fields). This step appears to be working o.k.
However, I also need to link the field [sample_type_secchi] on the
SecchiEntryParam_sub subform to [sample_type_weathercond] on the
WeatherCond_sub subform (these are text fields). I’ve made many attempts at
this but always get some sort of error message.
In the On Click Event of the command button, I have:
Private Sub OpenWeatherCond_Click()
On Error GoTo Err_OpenWeatherCond_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "WeatherCond"
stLinkCriteria = "[WeatherCondEvent_event_id]= " & Me![event_id] & "And"
& "Forms![WeatherCond]![WeatherCond_sub].Form![sample_type_weathercond]='" &
Me![sample_type_secchi] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_OpenWeatherCond_Click:
Exit Sub
Err_OpenWeatherCond_Click:
MsgBox Err.Description
Resume Exit_OpenWeatherCond_Click
End Sub
I haven’t been able to find any other examples of someone linking on one
field in the main form and a second in a subform, so I’m hoping this can be
accomplished somehow. Could someone please check out my code and see what I
am doing wrong?
Thank you!