• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 282
  • Last Modified:

MS Access Continuous Form - Retrieve row Key in VBA

What is the best way to retrieve a rows key value if you include the key field in the query but don't bind it to a text box?
0
AkAlan
Asked:
AkAlan
1 Solution
 
peter57rCommented:
In code you can use   me.keyfieldname   whether or not the field is on the form.  It must be in the form's recordsource of course.
0
 
AkAlanAuthor Commented:
Peter, Thanks, I had thought you could do that but when I tried to use that method to set a parameter directly in an ADODB Command, it didn't work, I had to first declare a variable, then set the variable to the keyvalue, then I used the variable in the Command.

Does Not work

Dim cmd as New ADODB.Command
With cmd
 .Parameters(@MyKeyValue") = Me.MyKeyValue


Does Work:

Dim myKeyValue as integer
myKeyValue = Me.MyKeyValue

Dim cmd as New ADODB.Command
With cmd
 .Parameters(@MyKeyValue") = myKeyValue
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

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