Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on 

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

Microsoft AccessMicrosoft DevelopmentMicrosoft Applications

Avatar of undefined
Last Comment
Larry Brister
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Try this

Me.scheduleComment = rst1![scheduleComment]

mx
Avatar of Larry Brister

ASKER

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
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo