jason bradway
asked on
Converting Varchar Value to DataType Int
I am getting the following Microsoft Visual Basic RunTime Error '245': Conversion failed when converting the varchar value '[Forms]![MedicalHistoryPh ysicalAdmi ssionLooku pForm]![Fa mily]' to data type int. When running the following code. Its driving me nuts as the value being passed is 108 and the field Family is data type INT as well as I have changed the form to reflect that it is a numeric field.
strSQL = " INSERT INTO MedHistoryPhysicalAdmission ( FAMILY, AdmissionDate )"
strSQL = strSQL & " SELECT Convert(int,'[Forms]![MedicalHistoryPhysicalAdmissionLookupForm]![Family]'), "
strSQL = strSQL & "'[Forms]![MedicalHistoryPhysicalAdmissionLookupForm]![AdmissionDate]';"
DoCmd.RunSQL (strSQL)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Phew! that solved my problem with Family now its giving me a problem with AdmissionDate but that might be a database issue. Runtime error 206: Operand Type Clash: int is incompatible with date.
The problem is probably due to the difference in the way dates are stored in Access and SQL Server.
That's assuming the AdmissionDate is a datetime field.
That's assuming the AdmissionDate is a datetime field.
Open in new window