Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2013
    Posts
    53

    Unanswered: Passing date parameter in continuous form with VBA

    Hello Access Experts!

    I'm running into run-time error 2482 when opening my form using the following code. The code errors out on "prm = Eval(prm.Name)"

    Code:
    Private Sub Form_Load()
    
        Dim dbs As DAO.Database
        Dim qdf As DAO.QueryDef
        Dim prm As DAO.Parameter
        Dim rst As DAO.Recordset
     
        Set dbs = CurrentDb()
        
        'DoCmd.OpenForm "_Daily_Checks", , , , , acDialog
            
        Set qdf = dbs.QueryDefs("_FBP_validate_all")
     
        For Each prm In qdf.Parameters
            prm = Eval(prm.Name)
        Next prm
     
        Set rst = qdf.OpenRecordset()
        
        rst.MoveLast
        
        rs.Close
        
        Set db = Nothing
        Set qdf = Nothing
    End Sub
    Essentially, the parameter query is captured in [_FBP_validate_all].[File_Date], however the continuous form record source is based on table [_0_FBP_all]. Both query and table have identical fields. I'm thinking this is where the error is but unsure how to solve...

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    is there a name property or method for DAO Parameter?
    why are you trying to assign the value of a property or method to the same (parameter) object, it doesn't make sense
    Code:
    For Each prm In qdf.Parameters
            prm = Eval(prm.Name)
        Next prm
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Jan 2013
    Posts
    53
    I set the name property to: Set prm = "[Enter Previous Date:]" and received a compile error, type mismatch.

    The value is assigned to different objects since I need to capture the entries made on the [_0_FBP_all] table but limit the results with a parameter query in [_FBP_validate_all].[File_Date].

    Perhaps I'm approaching this the wrong way?

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    You have a variable called prm, which is a dao parameter object
    in your code you iterate through qdf.parameters, each iteration uses prm as a temporary variable.
    you then assign the value of this objects name property to the same variable. I dont know what you are trying to do but this code is meaningless.

    Im not even certain there is a .name property or method for the dao.parameter object
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    As healdem, I'm not quite sure about what you're trying to achieve. However:
    Quote Originally Posted by VBAnewbie View Post
    I set the name property to: Set prm = "[Enter Previous Date:]" and received a compile error, type mismatch.
    It's not the Name property of the parameter that should be set to "[Enter Previous Date:]", it's its Value property.
    Have a nice day!

Posting Permissions

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