Results 1 to 2 of 2
  1. #1
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85

    Code only works after form is loaded 2nd time

    This is really strange to me.
    The code I am using is as follows:
    Code:
    Private Sub Form_Load()
    Dim strZip As String
    Dim strShipCost As String
    
    
    Me.ZipLookup = Left(Me.CustZipShip, 3)
    Me.Weight = DLookup("Weight", "tblEstimates", Me.[Branson Model Number])
    
    
    strZip = "Zip = '" & Me.ZipLookup & "'"
    strShipCost = "Weight = '" & Me!Weight & "' And Zone = '" & Me![Ship Zone] & "'"
    
    
    Me.Ship_Zone = DLookup("Zone", "tblGroundZones", strZip)
    Me.Ship_Cost = DLookup("Cost", "tblGroundShipRates", strShipCost)
    DoCmd.RefreshRecord
    End Sub
    When I open the form, [Ship_Cost] is blank.


    If I back out of the form, or go into design view, then go back to the form(view), [Ship_Cost] is then filled in correctly.
    Why isn't this working on the initial load of the form?


    Thanks!

  2. #2
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85
    I think I figured it out.

    Code:
    strZip = "Zip = '" & Me.ZipLookup & "'"
    
    Me.Ship_Zone = DLookup("Zone", "tblGroundZones", strZip)
    
    strShipCost = "Weight = '" & Me!Weight & "' And Zone = '" & Me![Ship Zone] & "'"

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

Similar Threads

  1. Replies: 8
    Last Post: 07-03-2015, 05:03 PM
  2. Replies: 1
    Last Post: 06-21-2015, 07:58 AM
  3. Replies: 2
    Last Post: 12-19-2014, 02:18 PM
  4. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  5. Replies: 6
    Last Post: 09-02-2012, 04:30 PM

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