Y
yator
I have a Form with 2 subforms. I need the ability to change the Child Field
on the second subform to a value found in a pop-up form. I have the following
structure:
FrmMain
Primary Key: ClientNo
FrmSubVisit
Record Source: q_frm_sub_visits_active
Field 1: Account
Field 2: AccDate
Link Child Fields: ClientNo
Link Master Fields: ClientNo
Default View: Continuous
FrmSubEvent
Record Source: q_frm_sub_events
Field 1: Account
Field 2: EventNo
Link Child Fields: Account
Link Master Fields: txtRelayAccount (text relay on FrmMain from frmSubVisit)
Default View: Single Form
The “Account†on frmSubEvent may need to be changed to a previous inactive
Account. A command button opens pop-up form FrmLookupVisit to find all
accounts related to the current ClientNo.
FrmLookupVisit
Record Source: tbl_visits
Field 1: Account
Field 2: EventNo
Default View: Continuous
A Command Button on the pop-up form should select a record and change
“Account†on frmSubEvent, and close the pop-up. I have tried the following
code on the On Click property of the VisitSelect button, but receive the
error:
“You can’t add or change a record because a related record is required in
table “tbl_Visitsâ€.
I am able to change the field manually with no problem.
Private Sub cboVisitSelect_Click()
Dim db As DAO.Database
On Error GoTo Err_cboVisitSelect_Click
Dim SQL As String
Set db = CurrentDb()
SQL = "UPDATE tbl_event " & _
"SET tbl_event.Account = '" & Me![Account] & "' " & _
" WHERE EventNo = " & Me![EventNo]
db.Execute SQL, dbFailOnError
Exit_cboVisitSelect_Click:
Exit Sub
Err_cboVisitSelect_Click:
MsgBox Err.Description
Resume Exit_cboVisitSelect_Click
End Sub
on the second subform to a value found in a pop-up form. I have the following
structure:
FrmMain
Primary Key: ClientNo
FrmSubVisit
Record Source: q_frm_sub_visits_active
Field 1: Account
Field 2: AccDate
Link Child Fields: ClientNo
Link Master Fields: ClientNo
Default View: Continuous
FrmSubEvent
Record Source: q_frm_sub_events
Field 1: Account
Field 2: EventNo
Link Child Fields: Account
Link Master Fields: txtRelayAccount (text relay on FrmMain from frmSubVisit)
Default View: Single Form
The “Account†on frmSubEvent may need to be changed to a previous inactive
Account. A command button opens pop-up form FrmLookupVisit to find all
accounts related to the current ClientNo.
FrmLookupVisit
Record Source: tbl_visits
Field 1: Account
Field 2: EventNo
Default View: Continuous
A Command Button on the pop-up form should select a record and change
“Account†on frmSubEvent, and close the pop-up. I have tried the following
code on the On Click property of the VisitSelect button, but receive the
error:
“You can’t add or change a record because a related record is required in
table “tbl_Visitsâ€.
I am able to change the field manually with no problem.
Private Sub cboVisitSelect_Click()
Dim db As DAO.Database
On Error GoTo Err_cboVisitSelect_Click
Dim SQL As String
Set db = CurrentDb()
SQL = "UPDATE tbl_event " & _
"SET tbl_event.Account = '" & Me![Account] & "' " & _
" WHERE EventNo = " & Me![EventNo]
db.Execute SQL, dbFailOnError
Exit_cboVisitSelect_Click:
Exit Sub
Err_cboVisitSelect_Click:
MsgBox Err.Description
Resume Exit_cboVisitSelect_Click
End Sub