troubleshooting Question

Object Required Error when calling Form Procedure from inside Access 2003 Form

Avatar of tom_trelford
tom_trelford asked on
Visual Basic Classic
20 Comments1 Solution376 ViewsLast Modified:
I have been away from Basic for several years and lots of things have changed.  I am converting a series of Excel
workbooks into a Access 2003 database.  The database design is simple, a Lots table with entries for each lot and a Subdivision table that has default values for various groups of lots.  The database has been loaded but I need to (1) set null values to 0, (2) retrieve and post the devaults into the lot records and then (3) update calculated values in the Lots records.

I have tried the following as a single procedure and as a module.  I am calling this single procedure from the single Form that is used for maintaining the Lots table.  Have been encountering the "Run Time Error 424 Object Required" error message and now am receiving the "Object Required" message on the "Set LotsRecId = Me!LotsRecId" line.  Cannot find any book or online references that makes this clear.

Am trying to do the Lot record updates first and then the population of the defaults.  Any recommendations are welcomed.
Thanks in advance for the help.  I have some co-workers that really, really want to get off of Excel.

Private Sub Form_Current()
    Dim LotsRecId As Integer
    Set LotsRecId = Me!LotsRecId
    If Me!BasePrice Is Null Then Set Me!BasePrice = 0
    If Me!PcntBase Is Null Then Set Me!PcntBase = 0
    If Me!LotPremium Is Null Then Set Me!LotPremium = 0
    If Me!PcntLotPrem Is Null Then Set Me!PcntLotPrem = 0
    If Me!Contract Is Null Then Set Me!Contract = 0
    If Me!PcntMarketing Is Null Then Set Me!PcntMarketing = 0
'    Dim mySQL As String
'    mySQL = "SELECT Lots.*, Subdivision.* " & _
'            "FROM Subdivision " & _
'            "INNER JOIN Lots ON Subdivision.[RecId]= Lots.[SubdivisionLink] " & _
'            "WHERE Lots.LotsRecId = LotsRecId"
'    myRecordSet.Open mySQL
'    If Me!GetDefaults = "Yes" And Me!SubdivisionLink <> "" Then
'        Set Me!PcntBase = Subdivision.PcntBase
'        Set Me!PcntLotPrem = Subdivision.PcntLotPrem
'        Set Me!PcntMarketing = Subdivision.PcntMarketing
'        Set Me!RTCFees = Subdivision.RTCFees
'        Set Me!FireFees = Subdivision.FireFees
'        Set Me!ParkFees = Subdivisione.ParkFees
'        Set Me!LotType = Subdivision.LotType
'        Set Me!GetDefaults = "No"
'        Debug.Print "Have updated the defaults"
'    End If
    If Me!PlanSqFt > 0 And Me!BasePrice > 0 Then
        Set Me!BasePriceSqFt = (Me!BasePrice + Me!Upgrades) / Me!PlanSqFt
    End If
    If Me!PlanSqFt > 0 And Me!Contract > 0 Then
        Set Me!TotalPriceSqFt = Me!Contract / Me!PlanSqFt
    End If
    Set Me!BaseAmtDue = Me!BasePrice * Me!PcntBase
    Set Me!LotPremDue = Me!LotPremium * Me!PcntLotPrem
    Set Me!MarketingFee = Me!PcntMarketing * Me!Contract
    Set Me!LotProceeds = Me!ListPrice + Me!LotDebt
    Set Me!TotalDue = Me!BaseAmtDue + Me!LotPremDue
    If Me!ActualClose <> "" Then
        Set Me!LotStatus = "CLOSED"
        ElseIf Me!EstClose <> "" Then
            Set Me!LotStatus = "IN ESCROW"
            ElseIf Me!DateSold <> "" Then
                Set Me!LotStatus = "SOLD"
                ElseIf Me!Reserved = "Yes" Then
                    Set Me!LotStatus = "RESERVED"
                    ElseIf Me!Released = "Yes" Then
                        Set Me!LotStatus = "RESERVED"
                        Set Me!LotStatus = "NOT RESERVED"
    End If
'    mySQL = "UPDATE Lots " & _
'            "WHERE Forms![Lots].RecId = LotsRecId"
'    DoCmd.RunSQL mySQL
End Sub
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 20 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros