+ Reply to Thread
Results 1 to 7 of 7

Open Form to Specific Record

  1. #1
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Cool Open Form to Specific Record

    Happy Friday VBA coders,

    I am aware that the thread title has been used elsewhere, however, after reading through them all am failing in an answer. The issue is as follows:

    In my Access Database I have the following items:
    1. A database with at least three columns: ID, WeekEnding, CustomerName.
    2. A user form that displays the individual records of the database for each of these columns (i.e Columnar). Each record is cycled using forward and back buttons.
    3. An entry form that contains a combo box and a Go button. The combo box lists the aforementioned user form.

    I am trying to load the userform and go to a specific record - namely, the record containing the current weekending date. I want to ensure all other records are still available (i.e. Not conditional).

    Please Login or Register  to view this content.
    The CurrentWeekEndingDate is determined when the entry form is loaded (Global Variable)

    The code does not produce an error. It opens the form but does not go to the required record.

    I am quite familiar with Word and Excel VBA, but Access VBA is new to me. Can anybody please provide a working example?

    Cheers

    Jrnymn

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Form to Specific Record

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Open Form to Specific Record

    Thank you for your response.

    Unfortunately your code produces a "Method or Data member not found" error.

    I tried using the following

    Please Login or Register  to view this content.
    The Microsoft Access database engine does not recognise "Jun" as a valid field name or expression.

    Since the current weekending date is 15-Jun-13, that is a problem. Note that the field (or column) contains only dates.

    Any further help would be appreciated.

    Also, what was CmbListForms.Bookmark = rs.Bookmark meant to do?

    Cheers

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Form to Specific Record

    What is in CurrentWeekEndingDate?

    Also what's the date type of the field WeekEnding?


    PS Where were you getting the 'Method.. not found... 'error?

  5. #5
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Open Form to Specific Record

    The CurrentWeekendingDate is a date. i.e 15-06-13. This variation is to make sure that the exact text of the field is returned.

    Each record has a unique date (although it's not the primary key).

    It is one of three columns in a table. It is to be used in a form such that when the form opens it automatically opens to the current weekending date.

    The method not found error was returned at this line:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Open Form to Specific Record

    My bad, I forgot CmbListForms was the combobox.

    Replace it with Forms(CmbListForms.Value).

    As for the criteria, I still don't quite understand where the value for CurrentWeekEndingDate is coming from.

    Is it declared and given a value somewhere else?

    By the way, if it is a date you probably want to wrap it in #.
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    03-05-2013
    Location
    Sydney
    MS-Off Ver
    Excel 2010
    Posts
    301

    Re: Open Form to Specific Record

    Thank you very much! Very happy.

    I didn't get that wrapping it in # for dates was required, and as soon as I added it, it worked exactly as intended.

    CurrentWeekEndingDate is determined by code at runtime. It's then compared against the predetermined list (table), and thanks to your assistance, displays the correct record when the form is opened.

    The end result is:

    Please Login or Register  to view this content.

    Many thanks once again

    Jrnymn

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1