Table of contents
TOC
Collapse the table of content
Expand the table of content

Handler Property Example (VB)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Applies to: Access 2013 | Access 2016

This example demonstrates the RDS DataControl objectHandler property. (SeeDataFactory Customization for more details.)

Assume that the following sections in the parameter file, Msdfmap.ini, are located on the server:


[connect AuthorDataBase] 
Access=ReadWrite 
Connect="DSN=Pubs" 
[sql AuthorById] 
SQL="SELECT * FROM Authors WHERE au_id = ?" 

Your code looks like the following. The command assigned to the SQL property will match the ** AuthorById** identifier and will retrieve a row for author Michael O'Leary. The DataControl object Recordset property is assigned to a disconnectedRecordset object purely as a coding convenience.


'BeginHandlerVBPublic Sub Main()
On Error GoTo ErrorHandlerDim dc As New DataControl
Dim rst As ADODB.Recordsetdc.Handler = "MSDFMAP.Handler"
dc.ExecuteOptions = 1dc.FetchOptions = 1
dc.Server = "http://MyServer"dc.Connect = "Data Source=AuthorDataBase"
dc.SQL = "AuthorById('267-41-2394')"dc.Refresh 'Retrieve the record
Set rst = dc.Recordset 'Use another Recordset as a convenienceDebug.Print "Author is '" &; rst!au_fname &; " " &; rst!au_lname &; "'"
' clean upIf rst.State = adStateOpen Then rst.Close
Set rst = NothingSet dc = Nothing
Exit SubErrorHandler:
' clean upIf Not rst Is Nothing Then
If rst.State = adStateOpen Then rst.CloseEnd If
Set rst = NothingSet dc = Nothing
If Err <> 0 ThenMsgBox Err.Source &; "-->" &; Err.Description, , "Error"
End IfEnd Sub
'EndHandlerVB

ACCESS SUPPORT RESOURCES
Access for developers forum on MSDN
Access help on support.office.com
Access help on answers.microsoft.com
Search for specific Access error codes on Bing
Access forums on UtterAccess
Access wiki on UtterAcess
Access developer and VBA programming help center (FMS)
Access posts on StackOverflow

© 2018 Microsoft