Results 1 to 6 of 6
  1. #1
    New Lounger
    Join Date
    Mar 2001
    Location
    Arkansas, USA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error 2115 (Access2K)

    I'm trying to set the beginning and ending dates of a date range into two text boxes based on the dates in two other text boxes and getting nowhere. The code looks like this:

    txtBeginDate2.Enabled = True
    txtBeginDate2.Locked = False
    txtBeginDate2.Visible = True
    txtEndDate2.Enabled = True
    txtEndDate2.Locked = False
    txtEndDate2.Visible = True

    txtEndDate.SetFocus
    strEndDate1 = txtEndDate.Text
    iMonth = Month(strEndDate1)
    iDay = 1
    iYear = Year(strEndDate1)
    strBeginDate2 = Format(iMonth, "00") & Format(iDay, "00") & Format(iYear Mod 100, "00")

    txtBeginDate2.SetFocus
    txtBeginDate2.Text = strBeginDate2 <-- ERROR 2115

    txtEndDate2.SetFocus
    txtEndDate2.Text = strEndDate1


    The error 2115 occurs on the assignment statement noted above,saying that the field's BeforeUpdate event or ValidationRule are preventing the completion of the assignment statement. If I ignore the error and Resume Next, the next error says that it can't move the focus to the next text field.

    What am I doing wrong?

  2. #2
    New Lounger
    Join Date
    Nov 2001
    Location
    Twickenham, UK
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error 2115 (Access2K)

    It sounds like you have specified a format for the txtBeginDate2 control (or the relevant field in your table) and the value of strBeginDate2 doesn't match this format.

    It looks to me (and I may well be wrong, but safe in the knowledge that someone will point it out if I am! <img src=/S/smile.gif border=0 alt=smile width=15 height=15>) like the value you are trying to pass to this field is actually only 6 digits, without any formatting (ie 022102 instead of 02/21/02). So, either remove the Date Format from the text box (or field) or try using something like this to make sure that strBeginDate2 is in Date format. Something like:

    strBeginDate2 = Format(iMonth, "00") & "/" & Format(iDay, "00") & "/" & Format(iYear Mod 100, "00")

    (I'm not sure if you should be declaring strBeginDate2 as a Date instead of a String) <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    Hope that helps..repost if I've sent you off on a wild goose chase.

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Error 2115 (Access2K)

    Where does this code actually live? Is it in an event procedure or somewhere else?

    You're using setfocus for no apparent reason that I can see unless it is so that you can use the control's .Text property. However, you don't need the Text property, you need the .Value property, and that doesn't require the setfocus at all.

    You appear to be mixing strings and dates as well. If your txtBeginDate2 and txtEndDate2 are bound controls and are bound to date/time fields, then you can't assign a string value to them and there is no reason for all the formatting you're doing. If txtEndDate contains a date, then you don't need to format it to assign it to txtBeginDate2, all you need to do is say this:

    txtBeginDate2 = txtEndDate
    Charlotte

  4. #4
    New Lounger
    Join Date
    Mar 2001
    Location
    Arkansas, USA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error 2115 (Access2K)

    It looks like I need to clarify some things.

    First, the four text boxes in question are unbound controls on a form that is used to initiate a report. There are two command buttons on the same form - one previews a report and the other prints the same report. The dates in these text boxes are used by the report's queries to limit the records selected to those BETWEEN two dates.

    So that's why I'm using text boxes and strings rather than date variables. If there's a better way, I'm listening.

    The code that I posted lives within the Click event for an option group which selects options for the report. Specifically, the option group determines how the dates going into the second two text boxes is related to the dates in the first two text boxes.

    I have probably left something out, but I think that answers the questions that have been posted so far. Thanks for your help, I have searched my ref books and found nothing.

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Error 2115 (Access2K)

    Yes, that does make it clearer, but if the fields in the query are true date/time fields, then you still don't need strings unless what you're actually doing is constructing a WhereCondition to open the report with or a filter to apply.

    Regardless, you don't need to setfocus to the controls to set their values, just set them directly. You also don't set the Text property in Access TextBoxes, you set their Value property, which is the default in all the existing versions of Access anyhow.
    Charlotte

  6. #6
    New Lounger
    Join Date
    Mar 2001
    Location
    Arkansas, USA
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Error 2115 (Access2K)

    Thanks, I got it working now. Changing the data type to Date and using the text box simply to display the Date value helped, but the bigger issue was using the Value property rather than the Text property of the text boxes. I had thought the Value property was only used to retrieve prior values of bound text boxes after an edit had started but before a record had been saved. Obviously I was wrong. Thanks loads - I'm on track again.

Posting Permissions

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