Results 1 to 14 of 14
  1. #1
    Join Date
    Mar 2004
    Posts
    287

    Unanswered: Ignore Access Error

    I have an error that appears oin a startup of a certain form and I can not find a way around it - pressing OK appears fine and it doesn't appear to be affecting the Database at all, so I want to remove the onscreen error message relating to it, how can i do this...

    The error states;
    Error -2147352567
    You entered an expression that has an invalid reference to the property Form/Report

    It appears to error on the following line in the form's VBA:
    SickAprPrev = Nz([Forms]![Main]![SubTotals]![SickAprPrev], 0)

    Which I can only assume due to the SubTotals being a subform on the main form as it opens hence why it errors (as it does njot exist yet until the main form fully opens).

    I have the database working so just need to ignore the error...

    Thanks,

    Neil

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Sounds like you need error handling in that procedure:

    Error trapping
    Paul

  3. #3
    Join Date
    Mar 2004
    Posts
    287
    copuld you explain more as i tried that codee and it still errored.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I think your problem is as you have identified that there is no value or no cotnrol available at the time the form loads.
    I suspect you need to make the sum control unbound (ie don't assign anything as part of the design), but assign the value using VBA

    if you assign the value in the forms on current event you should be OK
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Quote Originally Posted by NeilMansell View Post
    copuld you explain more as i tried that codee and it still errored.
    If Healdem's suggestion doesn't work, post your code. Hard to figure out what's going wrong when all you tell us is "it still errored".
    Paul

  6. #6
    Join Date
    Mar 2004
    Posts
    287
    i have a form with a subform on it, within the subform I have an unbound field named 'Day1' and 'Staffname'

    On the current event (I have also tried onopen, load, etc) i have the following looking up the data to display within that unbound field/text box...

    Code:
    Day1 = DLookup("[DayType]", "Qry_MainSelectStaff", "[Day] = 01/Jan/2011")
    All the tablkes and fields exist and have data (to test)

    By rights, the Day1 field checks for any data for the staff name (this part works and changes the records in the subform if I remove the dlookup code) and if there is an entry then displays the DayType field (eg: 'Hol') in the unbound field on the subform.

    I get the following error when running this way;

    Run-time error '2471'
    The expression you entered as a query parameter produced this error:
    'Jan'

    Any ideas?

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    date literals supplied to JET queries, and therefore domain functions should be US style (mm/dd/yyyy) and encapsulated with hash tags

    Day1 = DLookup("[DayType]", "Qry_MainSelectStaff", "[Day] = #01/01/2011#")

    you may get away with iso date format (yyyy/mm/dd)
    Day1 = DLookup("[DayType]", "Qry_MainSelectStaff", "[Day] = #2011/01/01#")
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Mar 2004
    Posts
    287
    thank you, that worked - sweet

  9. #9
    Join Date
    Mar 2004
    Posts
    287
    actually i have another error which I have been attrempting to resolve if you can help please;

    Code:
    Dim SelectedName As Integer
    SelectedName = Forms!Main!cboStaffName
    
    [Day1] = DLookup("[DayType]", "TBL_HolidayCard", "'[StaffName] =  SelectedName" And "[DayDate] = #01/01/2011#")
    Mismatch error -
    The SelectName is a combo box on the main form that has the staffname. If I run the query just with the name it works fine, so but I need to make it like above.

    Thanks,

  10. #10
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    another question, another thread, dems der rules
    why?
    contributors may not recognise this as a new problem, thinkign you had alreadey got a solution
    people following you looking for a solution may not find it if the questionis tagged onto another


    however just looking at the code its almost certainly a misplaced '
    you should encapsulate string literals with ' or "
    ...just the literal not the whole section or clause
    Code:
    [Day1] = DLookup("[DayType]", "TBL_HolidayCard", "'[StaffName] =  SelectedName" And "[DayDate] = #01/01/2011#")
    should read
    Code:
    [Day1] = DLookup("[DayType]", "TBL_HolidayCard", "[StaffName] =  SelectedName" And "[DayDate] = #01/01/2011#")
    I'd rather be riding on the Tiger 800 or the Norton

  11. #11
    Join Date
    Mar 2004
    Posts
    287
    thanks i actually just come to that conclusion as well after working out many different code lines

    This is part of the same problem so I will ask - the first part of the code is erroring again - type mismatch

    Code:
    Dim SelectedName As Integer
    SelectedName = [Forms]![Main]![cboStaffName]
    Again I have attempted all different forms of this VBA. All it is taking is a name from the combo box so the VBA code that is now fixed works out Day1 by the name selected and the date inserted in VBA.

  12. #12
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    you need to develop some debugging skills

    you need to post different questions in new threads

    you are trying to assign a control (on a form) to a variable of type integer
    ..wont work
    either assign the control to an object variable
    OR
    assign the value of a control to a variable of the appropriate type, which is what I suspect you want to do.

    so that would be
    Code:
    SelectedName = Forms!Main!cboStaffName.value
    ...it coudl be 'text, it could be some other property rather than value

    what id suggest you do is when the code halts examine the properties of the control in the debuggers' immediate window
    I'd rather be riding on the Tiger 800 or the Norton

  13. #13
    Join Date
    Mar 2004
    Posts
    287
    the immediate window is blank before and after it halts

  14. #14
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    yes thats what the immediate window normally does
    it allows you to either examine the state of various variables and it allows you to set the state of some variables

    as said before you need to develop some debugging skills
    ms access vba debugging - Google Search
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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