Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 3rd, 2004, 03:27 PM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Programming in Access Using VB

How does one, using VB, get access to the data in the fields of a row selected by a user? Drawing an analogy from excel, the activecell object is the range of the current selected cell. Various methods return information like the row number and value. Isn't there a similar object in Access? I couldn't find anything in the DAO or Access application object model. I could only find how to navigate through a recordset by using the various move methods.

I appreciate receiving any input on this problem.

Thank you.

 
Old November 4th, 2004, 05:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have a look at the field property of the recordset object. This is the equivalent to the Excel Cell.


Brian Skelton
Braxis Computer Services Ltd.
 
Old November 4th, 2004, 08:37 AM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

THe field property of the recordset object returns the first element of that field. The move methods allow you to navigate to other records in that field. However that is not what I am looking to do. I need to know the record number of a record selected by the user who is viewing a table. I can't seem to find a property that returns the record that is currently selected.

 
Old November 4th, 2004, 09:23 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you give us a few more details? How is the user selecting a record? Are they using tables directly or through a form? What exactly do you want to do with the selected record




Brian Skelton
Braxis Computer Services Ltd.
 
Old November 4th, 2004, 10:31 AM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for both of your responses.

I am talking about the case where a user is selecting a record from a table by clicking the record selecter. The table contains among other things, the names and addresses of clients.

My purposes is to create a custom menu where a user could choose to create an envelope , label or a return address on a letter by just selecting the record and clicking the custom menu item called "envelope" for example. The VB procedure would take the info from the client name and address fields and then create an enevelope throuh ms word. This is not the same as mail merge as the user is only interested in printing one envelope,letter of label for one client.



 
Old November 4th, 2004, 01:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 120
Thanks: 0
Thanked 0 Times in 0 Posts
Default

There's no way of doing this if the user is directly accessing a table. The UI to tables doesn't have an object model and cannot be programmed against.

What you can do is display the same data in a form. Once the user has navigated to the record they're interested in, you can then extract the information they're viewing, either by directly reading from the form's controls, or by using the form's recordsetclone property.


Brian Skelton
Braxis Computer Services Ltd.
 
Old November 4th, 2004, 03:23 PM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I thank you for your response. Much appreciated. I got the feeling that thsi wasn't possible. I think what I will do is have the user enter the number of the record , either into a dialog or input box, for that client for whom they want to produce an envelope or mailing label.

 
Old November 4th, 2004, 06:12 PM
Registered User
 
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just stumbled across the property I was looking for:
 Screen.ActiveDatasheet.CurrentRecord returns the record number of the selected object.








Similar Threads
Thread Thread Starter Forum Replies Last Post
PDA programming using VB 05 olink Visual Basic 2005 Basics 1 March 23rd, 2007 01:52 AM
Start Programming in VB.NET reality_42000 VB.NET 2002/2003 Basics 2 October 18th, 2006 05:40 AM
VB xml Programming helgaana1 Beginning VB 6 2 April 10th, 2005 11:03 AM
VB.NET Game Programming opportunities! brodel VB.NET 0 September 20th, 2003 08:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.