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
Solved

Set MS Access 22003 form control value to recordset field value

Posted on 2013-01-04
3
434 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

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…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

860 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