Results 1 to 8 of 8
  1. #1
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    408

    continuos form not more refreshing

    hi


    i have a continuos form based on my calendar, and near to the date of every task i have a button that adds a day, this is the code

    Code:
    Private Sub AddDayBtn_Click()   Me![Data inizio] = DateAdd("d", 1, Me![Data inizio])
    End Sub
    sure i'm making a lot of mess trying to add features, but till yesterday when i pressed the button automatically the date changed with the addedd day, now when i press the button nothing happens till i focus on the date
    why?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    till i focus on the date
    it is probably more to do with a record having the focus. Buttons are the same for each row and do not receive the focus for a specific row. So if you have not selected the row, your field either remains undefined or perhaps the first row (or the last row you selected) has the focus and that is where the value is being changed.

    As a test put something like

    debug.print me.ID

    in the first line of your code and see what it says

  3. #3
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    408
    it is the correct id, i tried with other field like "title" and it was as expected

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    there doesn't see any issue with your code - particularly if it used to work

    suggest upload your db for analysis - remove all tables and forms not required. Also remove or disable any code that starts automatically on open such as an autoexec macro or the display form property. Then compact then zip your file.

  5. #5
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    408
    here you are,
    even if i exported and delted every not necessary elements, the problem persists. Maybe is some setting i missed, i dont' know
    Attached Files Attached Files

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    your underlying field is being updated, but this is not reflected in your control until the control has the focus.

    I don't know why it would have been working in the past unless you had code which requeried or refreshed the control

    It is always better to refer to the control rather than the underlying controlsource. suggest change your code to

    Data = DateAdd("d", 1, Data)

  7. #7
    diegomarino is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2018
    Posts
    408
    you're damn right. i changed me!data to me![data inizio] for some reason, and i forgot that control name was "data".
    thanks i was almost to throw myself trough the window

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    I also strong suggest you put Option Explicit at the top of every module as you have some compilation errors which you won;'t otherwise find until runtime. To make this the default for new modules, in the VBA window go to Tools>Options and in the Editor tab, tick the 'require variable declaration' option

    It is also always better to use Me. rather than Me! because a) intellisense will work and b) any misspellings (such as this example) would have been highlighted on compilation. Reason is the . early binds the value, whilst ! late binds - and late binds are only found at runtime.

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

Similar Threads

  1. filters in continuos form using VBA code
    By TriFith in forum Access
    Replies: 5
    Last Post: 01-11-2017, 04:48 AM
  2. Refreshing Form and Subform
    By faythe1215 in forum Forms
    Replies: 6
    Last Post: 04-21-2016, 04:51 PM
  3. Replies: 1
    Last Post: 03-27-2015, 09:31 PM
  4. Sum textbox in continuos form
    By cuongmyh in forum Forms
    Replies: 2
    Last Post: 02-27-2015, 10:12 AM
  5. Replies: 1
    Last Post: 06-21-2013, 10:41 AM

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