Hello All,
I am unable to populate the records fetched from a recordset (r) in Form A into Form B.
This is Form A. In this form, I have 3 text boxes which are populated using a sql query that is stored in a recordset (r).
Once the user click on EDIT EMP INFO, it should use the CPS_REP_ID and populate additional data into Form B
Below is the code for the button click. The debug.print produces the desired output
This is form B
But whenever I click on the button, it always shows me #Name? on my new form.
I tried making sure that the Me.CPS_REP_ID is in quotes as it is a varchar value.
Is it a datatype issue or a control name issue?
Any guidance or help would be appreciated.
Thanks!
I am unable to populate the records fetched from a recordset (r) in Form A into Form B.
This is Form A. In this form, I have 3 text boxes which are populated using a sql query that is stored in a recordset (r).
Once the user click on EDIT EMP INFO, it should use the CPS_REP_ID and populate additional data into Form B
Below is the code for the button click. The debug.print produces the desired output
Code:
Private Sub btn_EDIT_EMPLOYEE_INFO_Click()
Dim strSQL As String
Dim r As New ADODB.Recordset
Dim DC As New DataConnection
strSQL = "SELECT P.CPS_REP_ID, P.CPS_FIRST_NAME, P.CPS_LAST_NAME, P.CURRENT_MEMBER, P.DATE_ADDED, " & _
"P.DATE_REMOVED, P.PREFERRED_FULL_NAME, P.EMAIL_ADDRESS, A.REASON_ADDED, R.REASON_REMOVED " & _
"FROM (Table A AS P LEFT JOIN TABLE REASONS_ADDED AS A ON P.REASON_ADDED = A.ID) LEFT JOIN " & _
"TABLE REASONS_REMOVED AS R ON P.REASON_REMOVED = R.ID WHERE P.CPS_REP_ID = '" & Me.CPS_REP_ID & "' ;"
r.Open strSQL, DC.CPS_DATA, adOpenKeyset, adLockOptimistic
Debug.Print r.Fields(0).Name
Debug.Print r.Fields(1).Name
Debug.Print r.Fields(2).Name
Debug.Print r.Fields(0).Value
Debug.Print r.Fields(1).Value
Debug.Print r.Fields(2).Value
DoCmd.OpenForm "frm_CPS_EDIT", acNormal
Set Forms("frm_CPS_EDIT").Recordset = r
Forms("frm_CPS_EDIT").Requery
DoCmd.Close acForm, "DASHBOARD", acSaveNo
End Sub
This is form B
But whenever I click on the button, it always shows me #Name? on my new form.
I tried making sure that the Me.CPS_REP_ID is in quotes as it is a varchar value.
Is it a datatype issue or a control name issue?
Any guidance or help would be appreciated.
Thanks!