Deleting record

MartynE

Registered User.
Local time
Today, 23:27
Joined
Mar 27, 2013
Messages
49
Hey all,

I'm trying to move a record from reservation to actual mutation.
It's almost done just the last bit of deleting the record in the reservation table us not working. It gives the data type mismatch error. I've tried several things but I'm missing something and that's what I need some help for.

Complete code for this button:
Code:
Private Sub Doorboeken_Click()

' Variabelen definiëren voor het vasthouden van data
    Dim AF_zaagbreedte, AF_lengte, AF_ordnr, AF_datum, VRID As String
    Dim ReserveringID As Integer
    Dim strSQLApp, strSQLDel As String

' Laden variabelen met de data op het formulier
    AF_zaagbreedte = Me.RES_zaagbreedte
    AF_lengte = Me.RES_lengte
    AF_ordnr = Me.RES_offertenr
    AF_datum = Me.RES_datum
    VRID = Me.VRID
    ReserveringID = Me.VRRESID
    

    
    strSQLApp = "INSERT INTO VRMUTSTAF (AF_zaagbreedte, AF_lengte, AF_ordnr, AF_datum, VRID) VALUES ('" & AF_zaagbreedte & "', '" & AF_lengte & "','" & AF_ordnr & "', '" & AF_datum & "', '" & VRID & "')"
    
[B]    strSQLDel = "DELETE FROM VRRESSTAF WHERE VRRESID = '" & ReserveringID & "'"[/B]

' SQL runnen om data over te zetten en te verwijderen

    DoCmd.RunSQL (strSQLApp)
    MsgBox ReserveringID
    DoCmd.RunSQL (strSQLDel)
    
    MsgBox "The Record has been moved"

End Sub

It gives the error on the bolded line of code.
 
I assume ReserveringID is a number, for a number you can't use quotes (makes it a string) so your SQL has to be:
Code:
strSQLDel = "DELETE FROM VRRESSTAF WHERE VRRESID = " & ReserveringID
 
I was playing with the quotes I knew it had to be something like that. Didn't know it was making a string of it. Thanks!
 
Is there any reason why my database crashes when I click this button. In design mode it works perfectly. Yet in the application it crashes 90% of the time.
Edit: When I just filled in a reservation I can click the button and it works, when I close the form and re-open this same record and click the button to move the record it crashes.
Edit2: Reason it crashed was that it didn't had the record focused.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom