TYPE CONVERSION FAILURE WITH TABLE UPDATE QUERY

Anonymous
2021-10-12T02:24:30+00:00

Hi,

I feel like I'm so close to solving a problem that has vexed me all day. My latest error when I attempt to update a table from an unbound form is a "Type Conversion Error". Here is the code:

DoCmd.RunSQL ("UPDATE [Participant Registration List] SET [Participant Registration List].[ACADEMY COHORT NUMBER]=' & Me.[ACADEMY COHORT NUMBER] & ', " & _

"[Participant Registration List].[COHORT START DATE]=' & Me.[COHORT START DATE] & ', " & _

"[Participant Registration List].[AGENCY NAMES]= '" & Me.[AGENCY NAMES] & "', " & _

"[Participant Registration List].[SEATS ALLOCATED]=' & Me.[SEATS ALLOCATED] & ', " & _

"[Participant Registration List].[EMPLOYEE ID NUMBER]= '" & Me.[EMPLOYEE ID NUMBER] & "', " & _

"[Participant Registration List].[EMPLOYEE LAST NAME]= '" & Me.[EMPLOYEE LAST NAME] & "', " & _

"[Participant Registration List].[EMPLOYEE FIRST NAME]= '" & Me.[EMPLOYEE FIRST NAME] & "', " & _

"[Participant Registration List].[EMPLOYEE HR TITLE]= '" & Me.[EMPLOYEE HR TITLE] & "', " & _

"[Participant Registration List].[EMAIL ADDRESS]= '" & Me.[EMAIL ADDRESS] & "', " & _

"[Participant Registration List].[PHONE NUMBER]= '" & Me.[PHONE NUMBER] & "', " & _

"[Participant Registration List].[LOS CITY]= '" & Me.[LOS CITY] & "', " & _

"[Participant Registration List].[TIME IN HR]= '" & Me.[TIME IN HR] & "', " & _

"[Participant Registration List].[GROUP]= '" & Me.[GROUP] & "', " & _

"[Participant Registration List].[AGENCY ABBREV]= '" & Me.[AGENCY ABBREV] & "'")

I think I understand that the type conversation error means that the code as written does not distinguish a text field from a number field from a datetime field. All three types are referred to in the above ("ACADEMY COHORT NUMBER" = NUMBER FIELD, "COHORT START DATE" = DATETIME FIELD, "SEATS ALLOCATED" = NUMBER FIELD, ALL OTHER FIELDS ARE 'SHORT TEXT' FIELDS) . . . but I don't know how to distinguish them. Please Please help.

I'd be so grateful to get some sleep tonight :)

Microsoft 365 and Office | Access | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

39 answers

Sort by: Most helpful
  1. ScottGem 68,855 Reputation points Volunteer Moderator
    2021-10-17T02:18:59+00:00

    Your diagram is not a properly normalized structure. You should have ONE courses table with a field that identifies the course as a Fundamental or Elective. You then need another table that would record the courses assigned to a person. Something like this:

    tblStudentCourse

    StudentCourseID (PK Autonumber)

    StudentID (FK)

    CourseID (FK)

    You might need other fields to identify when the course is taken, etc.

    I woud then use a mainform/subform combination with the mainform being bound to the Students table and the subform bound to tblStudentCourse. I would have an unbound control on the main form that would select either Fundamental or Elective. This would then filter the RowSource in a Combobox on the subform to filter for the type of course.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2021-10-16T20:13:37+00:00

    Hello, Imb_HB,

    Thank you for your response. I understand your recommendation to follow one track of learning at this point and will continue to do so.

    For your awareness, I believe I understand exactly what I'd like to accomplish - the task as i see it is to determine which approach will best lead me to my goal. To help you understand my goal, here is a diagram of my though process. Do you still believe it is simple and your approach is most appropriate?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2021-10-16T19:10:19+00:00

    Do you mind detailing what your alterative would look like? I'm sure it would help me tremendously.

    Hi toshitakae,

    In this stage of your learning process I think it is best to follow one track, and that is Tom's.

    If you fully understand what is going on, I would like to continue with the other track using a (DAO)recordset.

    It gives far better control of the input. It is relatively easy to make a system that adds a new record based on a couple of fields, or update an existing record.

    It is also possible to make conditional input or "afterupdate"-like actions.

    With respect to the construction of StrSQL, I use a little different typography, that is easier to read for the recognition of errors.

    In your case I see a missing space before "SET", and a missing space before "WHERE". And probably you need two times CHR(34), to enclose a string containing quotes.

    Succes.

    Imb.

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,855 Reputation points Volunteer Moderator
    2021-10-16T18:06:47+00:00

    Good morning, Tom

    Again, than you. Regarding Combo76, Since I’ve only hacked my way through Access for all so many years instead of taking the time to truly understand what I’m doing, I’ve often found it easier to copy something that has “worked” for me previously and simply modified it to a current need I have. (This is why I’ve never exposed a project to a true expert like you in all the years of ‘making my way through Access.). Therefore, it’s entirely possible that Combo76 may have been useful on a previous project, but only gets in the way this time.

    This is why we recommend that you don't accept the default name for controls and other objects, but to give them meaningful names.

    Was this answer helpful?

    0 comments No comments