[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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

Set MS Access 22003 form control value to recordset field value

Having to change a datasheet view form to single fomr

I'm getting my data in a recordset (1 row of data)

This works
        Dim cmd1 As New ADODB.Command
        Dim rst1 As ADODB.Recordset

        'Connect to db and run stored proc based on Client ID
        cmd1.ActiveConnection = CurrentProject.Connection
        cmd1.CommandType = adCmdStoredProc
        cmd1.CommandText = "usp_MarketingVisitationsGet"
        cmd1.Parameters("@ClientID") = Me.parent.txtClientID
        cmd1.Parameters("@VisitID") = Nz(Me.parent.cmbVisits, 0)

        'Set the recordset
        Set rst1 = cmd1.Execute(

Open in new window


How do I set Me.scheduleComment to the recordset value for scheduleComment?

On this...I'm getting an error message "Object required"

If Not rst1.EOF Then
    Me.scheduleComment = rst.scheduleComment
End If

Open in new window

0
lrbrister
Asked:
lrbrister
1 Solution
 
mbizupCommented:
Looks like you're using the wrong recordset name, and change the . to a !:

if Not rst1.EOF Then
    Me.scheduleComment = rst1!scheduleComment
End If

Open in new window

0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Try this

Me.scheduleComment = rst1![scheduleComment]

mx
0
 
lrbristerAuthor Commented:
Thanks...duhon me.

Also...
When I had to change this form from a data bound datasheet view form to a data editing form I forgot to "unbind" the controls.

Final Code
If Not rst1.EOF Then
    Me.txtClientID = rst1![Client ID]
    Me.ID = rst1!ID
    Me.requester = rst1!requester
    Me.cmbVisitStatus = rst1!visitStatus
    Me.scheduleComment = rst1!scheduleComment
    Me.departDate = rst1!departDate
    Me.meetingDate = rst1!meetingDate
    Me.returnDate = rst1!returnDate
End If
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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