Results 1 to 5 of 5
  1. #1
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Field not updating per code (2003)

    <P ID="edit" class=small>(Edited by masterd on 15-Jun-05 17:23. misspelling)</P>Hi,
    I have the below code. The data transferrs properly from one database to the other. The problem is the ysnMachineExported field is not being updated. The form is based off of the table. I've checked field names and can't seem to find anything wrong. Any ideas?
    Thanks,
    Deb


    Private Sub cmdUpdatePartsDB_Click()
    'check to see if this has already been exported
    ' If Me.ysnMachineExported = yes Then
    ' MsgBox "This machine has already been exported.", , "DSCR Talebook DB"
    ' Exit Sub
    ' End If

    If Me.Dirty Then
    RunCommand acCmdSaveRecord
    End If
    Dim dbFilePath As String
    dbFilePath = "t:Machine Parts Database.mdb"
    Dim theConnString As String
    theConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbFilePath
    Dim theInsertSQL As String
    theInsertSQL = "INSERT INTO tblMachineInformation " & _
    "(strMachineName, strMachID, strMachineJON, strMaterialJON, strMachineSerialNo, " & _
    "strMachineModelNo, strCustomer, lngContID, lngCARID, dtm4130CompletionDate, " & _
    "curAuthorizedAmt, intEstMechHrs, intEstElecHrs, intEstPEHrs, intEstSupHrs, " & _
    "intEstPCHHrs, curAuthPCH, curEstPCH, " & _
    "curAuthMechMaterial, curAuthRichMaterial, curEstMaterial, [dtmProject Start Date], " & _
    "ysnTDYJON, curAuthMaintenance) " & _
    "VALUES ('" & strMachineName & "','" & strMachID & "','" & strMachineJON & "','" & strMaterialJON & "','" & strMachineSerialNo & "'," & _
    "'" & strMachineModelNo & "','" & strCustomer & "'," & lngContID & "," & lngCARID & ",#" & dtm4130CompletionDate & "#," & _
    curAuthorizedAmt & "," & intEstMechHrs & "," & intEstElecHrs & "," & intEstPEHrs & "," & intEstSupHrs & "," & _
    intEstPCHHrs & "," & curAuthPCH & "," & curEstPCH & "," & _
    curAuthMechMaterial & "," & curAuthRichMaterial & "," & curEstMaterial & ",#" & [dtmProject Start Date] & "#," & _
    ysnTDYJON & "," & curAuthMaintenance & ")"
    Dim theConn As adodb.Connection
    Set theConn = New adodb.Connection
    DoCmd.Hourglass True
    theConn.Open theConnString, "Admin", ""
    theConn.Execute theInsertSQL
    theConn.Close
    Set theConn = Nothing
    Me.ysnMachineExported = yes
    DoCmd.Hourglass False
    MsgBox "The machine information is now available in the Parts Database.", , "DSCR Parts Database"
    End Sub

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    USA
    Posts
    386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field not updating per code (2003)

    I made a simple test using a command button and a checl box.

    me.ysn = yes did not change the filed on the form.
    I changed it to me.ysn = true and the check box updated.


    Hope this helps.
    Richard

  3. #3
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field not updating per code (2003)

    That seemed to work. Thank you!!!!!

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Field not updating per code (2003)

    Richard already solved your problem. If you had had Option Explicit at the top of the module, VBA would have warned you that "yes" was not recognized. You can - and should - add Option Explicit automatically to new modules by ticking Require Variable Declaration in Tools | Options in the Visual Basic Editor. See for example <post#=314748>post 314748</post#> for a short explanation why this is useful.

  5. #5
    4 Star Lounger
    Join Date
    Oct 2002
    Location
    Sayre, Pennsylvania, USA
    Posts
    504
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field not updating per code (2003)

    Thank you Hans.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •