Go To Current Record

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony

    Go To Current Record

    Hello,

    I am having difficulty in getting the current record of the current
    form to show after pressing a command button that takes me to another
    form. The command button takes me to another form that I want to show
    the record of the previous form I left.

    The problem is that the form does not show any other record but the
    current one from the previous form. I want it to open to that current
    record and it does however I can only view that record. If I try to
    page up or down then it will not let me. I think that there are a few
    different ways to do this but I am doing it as a macro.

    The macro starts with OpenForm. Then in the where condition I entered
    [certificate]=[Forms]![frmECInput]![certificate].
    It does work but I want to be able to also use page up down to see
    other records. I also saw a command for "ShowAllRecords " but it did
    not start at the current record.

    Does anybody know how to make all records appear starting with the
    current record from another form? I also tried "goto" command but it
    did not work either.


    thank you,
    Tony
  • xzzy

    #2
    Re: Go To Current Record

    some different ways to do it:

    1. select a record in the form: frmECInput then

    when refreshing the screen to sync try resetting the recordsource to
    something like:

    select * from table where [certificate]>=[Forms]![frmECInput]![certificate]
    order by [certificate]


    2. or if its closed, then when opening it, pass a where cluase to it like

    docmd.openform "formname", "", "[certificate]>='" &
    [Forms]![frmECInput]![certificate] & "'"



    3. Beware of hard coding names in your app, if something changes then you
    would have to change all occurances of what changed, so this is better:

    a. define a global variable
    Global strCertificate as string

    and a function to pass the variable

    Public function GetCertificate( ) as string
    if len(strCertific ate) = 0 then
    strCertificate = "ERROR"
    GetCertificate = strCertificate
    else
    GetCertificate = strCertificate
    end if
    end function


    b. use the selecting form's oncurrent event to keep track of where you are
    in frmECInput OnCurrent event
    strCertificate = ctlCertificate


    c. open/refresh/whatever the selected form
    docmd.openform "formname",""," certificate = '" & GetCertificate( ) & "'"

    the advantages of this way are you are using good data, and the references
    are not hardcoded.


    4. Using a class to do your task may or may not apply to your situation. The
    above mixes the data and the front end, most access apps do their work this
    way. A class enables you to separate the front end, from business rules,
    and from the acquisition of data, and from the data itself. ( meaning a
    change to the data or business rules does not require changes to the front
    end ) I'd explain classes, but if you are using
    [Forms]![frmECInput]![certificate] to reference something, get the above to
    work and then learn about classes next week.

    sorry if i mistyped something, but your get the idea.

    John Bickmore



    "Tony" <ett@wt.net> wrote in message
    news:ad1cfe07.0 312151900.45f91 144@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > I am having difficulty in getting the current record of the current
    > form to show after pressing a command button that takes me to another
    > form. The command button takes me to another form that I want to show
    > the record of the previous form I left.
    >
    > The problem is that the form does not show any other record but the
    > current one from the previous form. I want it to open to that current
    > record and it does however I can only view that record. If I try to
    > page up or down then it will not let me. I think that there are a few
    > different ways to do this but I am doing it as a macro.
    >
    > The macro starts with OpenForm. Then in the where condition I entered
    > [certificate]=[Forms]![frmECInput]![certificate].
    > It does work but I want to be able to also use page up down to see
    > other records. I also saw a command for "ShowAllRecords " but it did
    > not start at the current record.
    >
    > Does anybody know how to make all records appear starting with the
    > current record from another form? I also tried "goto" command but it
    > did not work either.
    >
    >
    > thank you,
    > Tony[/color]


    Comment

    • Tony Johnson

      #3
      Re: Go To Current Record

      John,

      Thank you for your reply. I will try that first one to see if it works.
      I am not too familiar with all of the other ones because I am just a
      novice user of access but I certainly want to learn a lot more.

      Thank you,
      Tony



      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      Working...