Results 1 to 3 of 3
  1. #1
    d4jones is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    4

    converted coding issues.

    I converted a database from 97 to 2010, and i have a form that gives an option to select a ck box

    here's the code, can some please help me with what i need to change. PLEASE!!!! it's driving me nuts!!!

    I'm getting an error - Invalid use of property

    Option Compare Database
    Option Explicit

    Public Sub Button135_Click()

    Dim DocName As String
    Dim LinkCriteria As String

    On Error GoTo ErrorHandler:
    DocName = "Loan Vehicle RENT"
    DoCmd.OpenForm DocName, , , LinkCriteria

    ExitRoutine:
    Exit Sub

    ErrorHandler:
    MsgBox Error$()
    Resume ExitRoutine

    End Sub

    Public Sub Command140_Click()

    End Sub

    Public Sub Command139_Click()

    If IsNull(Controls("Unit")) Then

    Beep
    MsgBox "You do not have the unit master file open. Close application and reopen", _
    vbCritical, "Unit"
    End

    ElseIf IsNull(Controls("Reason")) Then

    Beep
    MsgBox "You do not have the Reason for this Workorder listed.", _
    vbCritical, "Unit"
    End

    ElseIf Controls("Mileage") < 1 Then

    Controls("Mileage") = Controls("CURRENT")

    End If

    Forms("Company Profile").Controls("Workorder Number").Requery
    Controls("Workorder Number") = Forms("Company Profile").Controls("Workorder Number") + 1
    Forms("Company Profile").Controls("Workorder Number") = Forms("Company Profile").Controls("Workorder Number") + 1
    DoCmd.Close acForm, "Company Profile"
    DoCmd.OpenForm "Company Profile", , "", "", acFormEdit, acHidden

    If Controls("NEED PM") = 2 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")

    ElseIf Controls("NEED PM") = 3 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")
    Me.PMforWO.Form.Controls("pm2 miles") = Controls("Mileage")


    Me.PMforWO.Form.Controls("PM2 DATE") = Controls("Date")

    End If

    DoCmd.DoMenuItem 0, 0, 4, 0, 70
    Forms("Unit Master Form").Controls("Miles") = Controls("Mileage")
    DoCmd.SetWarnings False
    Controls("Workorder Number").SetFocus
    DoCmd.DoMenuItem 0, 0, 4, 0, 70
    Forms("main menu").Controls("wo") = Controls("Workorder Number")
    DoCmd.RepaintObject acForm, "Workorder CREATE"

    If Controls("PMTYPE") <> "No" Then

    DoCmd.RunSQL "INSERT INTO [Workorder Detail Parts] ( [Workorder Number], Unit, SY, [Part Number], Qty, [Part Cost], Description, [Total Amount], TAX )SELECT DISTINCTROW [Forms]![Workorder CREATE]![Workorder Number] AS [Workorder Number], [Forms]![Workorder CREATE]![UNIT] AS Unit, [pm kit].Sy, [pm kit].[Part Number], [pm kit].Qty, [pm kit].[Part Cost], [pm kit].Description, [pm kit].[Total Amount], [pm kit].TAX FROM [pm kit]WHERE ((([pm kit].[PM type])=[Forms]![Workorder CREATE]![PMTYPE]));"

    If Controls("NEED PM") = 2 Then

    Controls("PMTYPE") = "PM1"

    ElseIf Controls("NEED PM") = 3 Then

    Controls("PMTYPE") = "PM2"

    End If

    Else

    Controls("PMTYPE") = " "

    End If

    DoCmd.DoMenuItem 0, 0, 4, 0, 70
    DoCmd.RepaintObject acForm, "Workorder CREATE"

    If Controls("Repair Site") = 1 Then

    DoCmd.Close acForm, "Workorder CREATE"
    DoCmd.OpenReport "Workorder work page", , "", ""
    DoCmd.OpenReport "Workorder PARTS page", , "", ""

    Else

    DoCmd.Close acForm, "Workorder CREATE"
    DoCmd.OpenReport "Workorder work page OS", , "", ""

    End If

    End Sub

    Public Sub Command141_Click()

    On Error GoTo ErrorHandler:
    Undo
    DoCmd.Close

    ExitRoutine:
    Exit Sub

    ErrorHandler:
    MsgBox Err().Description
    Resume ExitRoutine

    End Sub

    Public Sub Command152_Click()

    On Error GoTo ErrorHandler:
    DoCmd.DoMenuItem acFormBar, acEditMenu, acSelectRecord, , acMenuVer70
    DoCmd.DoMenuItem acFormBar, acEditMenu, acDelete, , acMenuVer70

    ExitRoutine:
    Exit Sub

    ErrorHandler:
    MsgBox Err().Description
    Resume ExitRoutine

    End Sub

    Public Sub Command164_Click()

    Dim stDocName As String
    Dim stLinkCriteria As String

    If IsNull(Controls("Unit")) Then

    Beep
    MsgBox "You do not have the unit master file open. Close application and reopen", _
    vbCritical, "Unit"
    End

    ElseIf IsNull(Controls("Reason")) Then

    Beep
    MsgBox "You do not have the Reason for this Workorder listed.", _
    vbCritical, "Unit"
    End

    ElseIf Controls("Mileage") < 1 Then

    Controls("Mileage") = Controls("CURRENT")

    End If

    Forms("Company Profile").Controls("Workorder Number").Requery
    Controls("Workorder Number") = Forms("Company Profile").Controls("Workorder Number") + 1
    Forms("Company Profile").Controls("Workorder Number") = Forms("Company Profile").Controls("Workorder Number") + 1
    DoCmd.Close acForm, "Company Profile"
    DoCmd.OpenForm "Company Profile", , "", "", acFormEdit, acHidden

    If Controls("NEED PM") = 2 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")

    ElseIf Controls("NEED PM") = 3 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")
    Me.PMforWO.Form.Controls("pm2 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM2 DATE") = Controls("Date")

    End If

    DoCmd.RunCommand acCmdSaveRecord
    Forms("Unit Master Form").Controls("Miles") = Controls("Mileage")
    Forms("Unit Master Form").Controls("Hours") = Controls("Hours")
    DoCmd.SetWarnings False
    Controls("Workorder Number").SetFocus
    DoCmd.RunCommand acCmdSaveRecord
    Forms("main menu").Controls("wo") = Controls("Workorder Number")
    DoCmd.RepaintObject acForm, "Workorder CREATE"

    If Controls("PMTYPE") <> "No" Then

    DoCmd.RunSQL "INSERT INTO [Workorder Detail Parts] ( [Workorder Number], Unit, SY, [Part Number], Qty, [Part Cost], Description, [Total Amount], TAX )SELECT DISTINCTROW [Forms]![Workorder CREATE]![Workorder Number] AS [Workorder Number], [Forms]![Workorder CREATE]![UNIT] AS Unit, [pm kit].Sy, [pm kit].[Part Number], [pm kit].Qty, [pm kit].[Part Cost], [pm kit].Description, [pm kit].[Total Amount], [pm kit].TAX FROM [pm kit]WHERE ((([pm kit].[PM type])=[Forms]![Workorder CREATE]![PMTYPE]));"

    If Controls("NEED PM") = 2 Then

    Controls("PMTYPE") = "PM1"

    ElseIf Controls("NEED PM") = 3 Then

    Controls("PMTYPE") = "PM2"

    End If

    Else

    Controls("PMTYPE") = " "

    End If

    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.RepaintObject acForm, "Workorder CREATE"

    If Controls("Repair Site") = 1 Then

    stDocName = "woinputs2"
    stLinkCriteria = "[Workorder Number]=" & Controls("Workorder Number")
    DoCmd.Close acForm, "Workorder CREATE"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.Maximize
    DoCmd.SetWarnings True

    Else

    stDocName = "woinputsOS"
    stLinkCriteria = "[Workorder Number]=" & Controls("Workorder Number")
    DoCmd.Close acForm, "Workorder CREATE"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.Maximize
    DoCmd.SetWarnings True

    End If

    End Sub

    Public Sub NO_PM_GotFocus()

    Controls("PMTYPE") = "NO"

    End Sub

    Public Sub PM1_GotFocus()

    Controls = ("PMTYPE") = Controls("Kit11")

    End Sub

    Public Sub PM2_GotFocus()

    Controls("PMTYPE") = Controls("Kit22")

    End Sub

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Have you stepped through the code to see which line is causing the error? That is a lot of code to look through. Since we don't have the tables, forms or queries, it will be difficult to find the error.

    I did notice that in the following code, you should NOT have the first equals sign (in red):
    Code:
    Public Sub PM1_GotFocus()
    
       Controls = ("PMTYPE") = Controls("Kit11")
       
    End Sub
    I think it should be:

    Controls("PMTYPE") = Controls("Kit11")

  3. #3
    d4jones is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    4
    thank you, I fixed that now, I'm getting this error "run-time error '2448': you can't assign a value to this object" on this line of code.

    If Controls("NEED PM") = 2 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")

    ElseIf Controls("NEED PM") = 3 Then

    Me.PMforWO.Form.Controls("pm1 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM1 DATE") = Controls("Date")
    Me.PMforWO.Form.Controls("pm2 miles") = Controls("Mileage")
    Me.PMforWO.Form.Controls("PM2 DATE") = Controls("Date")

    End If

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Coding for message box
    By tomneedshelp in forum Forms
    Replies: 3
    Last Post: 03-23-2012, 02:33 PM
  2. Please help with VB coding
    By winterh in forum Import/Export Data
    Replies: 11
    Last Post: 03-19-2012, 06:05 PM
  3. Need help in VBA coding
    By Kcgp in forum Programming
    Replies: 6
    Last Post: 02-01-2012, 11:22 PM
  4. Button Coding
    By yamie in forum Programming
    Replies: 3
    Last Post: 02-22-2010, 10:45 AM
  5. Bar-Coding
    By texasprincess7 in forum Access
    Replies: 1
    Last Post: 02-12-2009, 10:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums