Solved

Set MS Access 22003 form control value to recordset field value

Posted on 2013-01-04
3
409 Views
Last Modified: 2013-01-04
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
Comment
Question by:lrbrister
3 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38745245
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
 
LVL 75
ID: 38745248
Try this

Me.scheduleComment = rst1![scheduleComment]

mx
0
 

Author Closing Comment

by:lrbrister
ID: 38745318
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
User Beware!  This is a rather permanent solution to removing your email from an exchange server.  The only way to truly go back is to have your exchange administrator restore your mailbox from backups.  This is usually the option of last resort.  A…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now