Solved

Set MS Access 22003 form control value to recordset field value

Posted on 2013-01-04
3
442 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 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