Re: populating a field in a record
Hi, I have a question on populating a field on a form from another form. I have a form(frm_customer) that opens to a filtered form(frm_ear). W/i the frm_ear user wants to populate the customer id field from frm_customer when add a new record through record selectors control in Access.
In click event in frm_customer
Private Sub view customer ears_Click()
On Error GoTo Err_Command32_Click
Dim stDocName As String
stDocName = "ear"
DoCmd.OpenForm stDocName, , , "[customer id]=" & Me![customer ID]
Exit_view customer ears_Click:
Exit Sub
Err_view customer ears_Click:
MsgBox Err.Description
Resume Exit_view customer ears_Click
End Sub
I'm created a button on frm_ear and saved the customer id to a variable before moving to the new record.
Private Sub cmdAdd_record_Click()
On Error GoTo Err_cmdAdd_record_Click
Dim cust_id As Integer
cust_id = Me![customer ID].Value
DoCmd.GoToRecord , , acNewRec
Me![customer ID].Value = cust_id
Exit_cmdAdd_record_Click:
Exit Sub
Err_cmdAdd_record_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_record_Click
End Sub
Is there a better way to do this?What is the code I need to populate the customer id field from record selectors control ? Thanks much!
Hi, I have a question on populating a field on a form from another form. I have a form(frm_customer) that opens to a filtered form(frm_ear). W/i the frm_ear user wants to populate the customer id field from frm_customer when add a new record through record selectors control in Access.
In click event in frm_customer
Private Sub view customer ears_Click()
On Error GoTo Err_Command32_Click
Dim stDocName As String
stDocName = "ear"
DoCmd.OpenForm stDocName, , , "[customer id]=" & Me![customer ID]
Exit_view customer ears_Click:
Exit Sub
Err_view customer ears_Click:
MsgBox Err.Description
Resume Exit_view customer ears_Click
End Sub
I'm created a button on frm_ear and saved the customer id to a variable before moving to the new record.
Private Sub cmdAdd_record_Click()
On Error GoTo Err_cmdAdd_record_Click
Dim cust_id As Integer
cust_id = Me![customer ID].Value
DoCmd.GoToRecord , , acNewRec
Me![customer ID].Value = cust_id
Exit_cmdAdd_record_Click:
Exit Sub
Err_cmdAdd_record_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_record_Click
End Sub
Is there a better way to do this?What is the code I need to populate the customer id field from record selectors control ? Thanks much!