Hi,
I am a total newbie with access databases, litterally 2nd day. I am trying to populate a textbox and the related control source table field with a select criteria.
Basically on the form you select a Job Title from a combobox then enter a division and I am trying to get it to select the "Code" that relates to that job.
The job details are held in a database view [TMC_PDT_DETAILS]
The forms source is the [PAFTable] but the actual values I want to refer to come from the form controls [JobTitle] and [Div].
I referenced these first then included them in my SQL string, but I keep getting various errors (I have tried many things)
I have tried both docmd.RunSQL and docmd.openQuery the later gets a 7874 error and the first gets 3075.
Nb I have had to remove the square brackets round .Code as it opened the code quotes from there
I am a total newbie with access databases, litterally 2nd day. I am trying to populate a textbox and the related control source table field with a select criteria.
Basically on the form you select a Job Title from a combobox then enter a division and I am trying to get it to select the "Code" that relates to that job.
The job details are held in a database view [TMC_PDT_DETAILS]
The forms source is the [PAFTable] but the actual values I want to refer to come from the form controls [JobTitle] and [Div].
I referenced these first then included them in my SQL string, but I keep getting various errors (I have tried many things)
I have tried both docmd.RunSQL and docmd.openQuery the later gets a 7874 error and the first gets 3075.
Code:
Private Sub Div_AfterUpdate()
Dim SQLstr As String, Job As String, Division As String
Job = JobTitle
Division = Div
SQLstr = "SELECT [TMC_PDT_DETAILS].Code " & _
"AS F2 " & _
"FROM [TMC_PDT_DETAILS] " & _
"WHERE [TMC_PDT_DETAILS].[Job Title]= """ & Job & "" & _
"AND [TMC_PDT_DETAILS].[Division Code] = """ & Division & """;"
DoCmd.RunSQL SQLstr
JobCode = F2
End Sub
Last edited: