Link to home
Start Free TrialLog in
Avatar of f_o_o_k_y
f_o_o_k_yFlag for Poland

asked on

Accessing current recod data form VB

Hello,

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
fooky
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

Avatar of f_o_o_k_y

ASKER

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

But about MS Access
Give me a minute and I will post the answer
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
    .Delete
End With

dbGrupo.Close
You can refer to any field in the form's underlying recordset like this:

Forms("NameOfYourForm")!SomeField

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

Me!SomeField

Note the ( ! ) operator ...

LSMConsulting:

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.



ASKER CERTIFIED SOLUTION
Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
LSMConsulting great but I know how to remove it. But than i cant access it data!!!