Accessing current recod data form VB

Posted on 2007-07-20
Last Modified: 2008-02-01

When I'm creating form based on query I have all fields added automaticly to my form.
I want to delete for example someID field (textbox) but I still need to access this field from my VB code.

Can I access current record data somehow???
I dont know VB much but meybe somthing like Me.Recordset.column("someID");

Best Regards
Question by:f_o_o_k_y
    LVL 48

    Expert Comment

    LVL 11

    Author Comment

    Upsss my mistake, wrong group.
    This question is not about ms

    But about MS Access
    LVL 48

    Expert Comment

    Give me a minute and I will post the answer
    LVL 48

    Expert Comment

    I think it's this that you want!

    Dim dbGrupo As Recordset
    Dim db As Variant
    Dim SQL As String

    Set db = CurrentDb
    SQL = "SELECT * FROM mytable WHERE ID = " & InputBox("my messa")
    Set dbGrupo = db.OpenRecordset(SQL)

    With dbGrupo
    End With

    LVL 84
    You can refer to any field in the form's underlying recordset like this:


    or, if you're running the code on the form, just use Me:


    Note the ( ! ) operator ...

    LVL 11

    Author Comment


    Yes I know that i can access any filed i that way.

    But i need something else.

    I have for example :

    SELECT someID, someName FROM someTable

    And i save it as my query:  Query1

    Than I create new Form1 based on that Query1

    Access automagically :) creates text fields:
    someID, someName
    and lables someID, someName

    I can access id for example: Me!someID.Value

    But I need to remove field someID from Form1(I dont want to see it in my Form1)
    (but remeber that my Form1 is still based on Quer1 so I should be able to access someID for current displayed record)

    How to do this.

    LVL 84

    Accepted Solution

    Either (a) remove it from the form, or (b) make the control invisible. To remove it, open the form in Design view, highlight the control and press the Delete key. To make it invisible, highlight the control and set the Visible property of the control to False.
    LVL 11

    Author Comment

    LSMConsulting great but I know how to remove it. But than i cant access it data!!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now