[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

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
0
f_o_o_k_y
Asked:
f_o_o_k_y
  • 3
  • 3
  • 2
1 Solution
 
f_o_o_k_yAuthor Commented:
Upsss my mistake, wrong group.
This question is not about ms VB.net

But about MS Access
0
 
jpaulinoCommented:
Give me a minute and I will post the answer
0
Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
jpaulinoCommented:
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
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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 ...

0
 
f_o_o_k_yAuthor Commented:
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.



0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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.
0
 
f_o_o_k_yAuthor Commented:
LSMConsulting great but I know how to remove it. But than i cant access it data!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now