INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Problem cloning data from a subform

Problem cloning data from a subform

(OP)
I could really do with some help if someone has got the time.

I'm working on a function that, in theory, will clone all the data from my main form and those related registers from a subfrom (in the main from).
While the cloning of the data in the main form is working correctly, I'm having dificulties cloning the data from the subform.

Obviosuly, the data in the subform is tied to a query, here below is the setup of the table in the subform [Servicios_Pasajeros] :

Table Name: Pasajeros_Servicios

Field name / Property
ID / AutoNumber
ID_Servicio / Text (holds the same value as ID)
Posicion / Text
Nombre / Text
Apellido_1 / Text
Apellido_2 / Text
Nacionalidad / Text

Here's the code that I'm working on:
Important to mention that this code is not mine, it was posted by Allen Browne in 2005 (allenbrowne.com)

Dim lngID As Long
Dim strSQL As String


lngID = Me.ID_Servicio
If Me.[Servicios_Pasajeros].Form.RecordsetClone.RecordCount > 0 Then

strSQL = "INSERT INTO [Pasajeros_Servicios] ( ID_Servicio, Posicion, Nombre, Apellido_1, Apellido_2, Nacionalidad ) " & _
"SELECT " & lngID & " As NewID, Posicion, Nombre, Apellido_1, Apellido_2, Nacionalidad " & _
"FROM [Pasajeros_Servicios] WHERE ID_Servicio = " & Me.ID_Servicio & ";"
DBEngine(0)(0).Execute strSQL, dbFailOnError

Else
' Msgbox "No data to clone"
End If


After execution, I get the following error: Data type mismatch in criteria expession.


While I understand what the code is doing, I'm unable to see the cause of the error.
Anyones help would be great..


JMC014


RE: Problem cloning data from a subform

I would first put in a debug.print statement so we can see the actual sql string.
My first guess is that ID_Servicio is not a long in the table you are inserting it to or getting it from.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close