Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulating the values in the fields from the Current Record

Status
Not open for further replies.

sesproul

IS-IT--Management
Aug 21, 2009
5
US
Hello,

this is the first time I have ever manipulated the data associated with a FORM, with VB (I know VB very well, just not the ACCESS interface)

I want to take the Value in a field VENDOC_DOC_Path, and pass the value to a shell command to launch the file outside of ACCESS, when a button on a form is pushed.

So How do I grab access to the field from VBA?


thanks

Steve
 
If you are using the a form event so you are in its class module...

Me![Field Name] 'Square brackets allow use of spaces or other special characters

Fields/Controls are the default collection of the form object and value is the default property of the field.

Alternately...

Me.Fields("Field Name").Value

And if you are not on that form...

Forms![Form Name]![Field Name] 'Hint you can get this by building criteria in a query
 
Thank you. It works well.


When you say "building criteria in a query" is that an option when creating Queries? because I definately would like to be able to pass variables to Queries, but haven't figured that out yet.



Steve
 
Yes if you are in the quey designer you can right click in the criteria row for an appropriate field and select build.

Then you navigate the 3 panes at the bottom and double click the element you want. The left side of the comparison is implied so if you see the following in the query designer under Created_date...

Code:
      >= #5/1/2000# and <= Date()

The SQL will look like...

Code:
      Where Created_date >= #5/1/2000# and Created_date <= Date()

Other than that, the Designer AND's criteria across and Or's it down.

In the designer you can define your parameters by right clicking in the grey space where the tables are and selecting parameters (without looking I think it is also on the view menu). The parameter on the left side is the text as it appears in the query but of course has to meet syntax requirements. The good thing about this is you can define the datatype this way and you should do this for all but text parameters. Apparently there is a bug, I don't have a link handy but Allen Browne (sp?) has a web site that covers these types of bugs.

Also noteworthy is that Access coniders everything in Square brackets a field / parameter. If it can't find the field you will get a prompt at execution time. Technically you could do something like [red][Enter Start Date][/red] [noevil] but we would be embarrassed for you as parameters should obviously go back to forms.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top