[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Trying to write values from a listbox to an unbound table

Posted on 2014-01-17
3
Medium Priority
?
417 Views
Last Modified: 2014-01-18
I'm trying to write values from a listbox to an unbound table.

My code isn't working.

Here it is:

    Dim RS As DAO.Recordset
        Set RS = CurrentDb.OpenRecordset("tblReady")
            RS.AddNew
            RS!Bay = Forms!frmPlanted.ListBayQty.Bay
            RS!ReadyQty = Forms!frmPlanted.ListBayQty.ReadyQty
            RS.Update

????
0
Comment
Question by:SteveL13
[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 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 1000 total points
ID: 39789919
You refer to columns in a listbox by their index (which is zero-based):

Dim RS As DAO.Recordset
        Set RS = CurrentDb.OpenRecordset("tblReady")
            RS.AddNew
            RS!Bay = Forms!frmPlanted.ListBayQty.Column(0)
            RS!ReadyQty = Forms!frmPlanted.ListBayQty.Column(1)
            RS.Update

If the code is running on frmPlanted:

            RS.AddNew
            RS!Bay = Me.ListBayQty.Column(0)
            RS!ReadyQty = Me.ListBayQty.Column(1)
            RS.Update

Obviously you'd have to change the Column(x) values to match those in your listbox.
0
 
LVL 38

Assisted Solution

by:Jim P.
Jim P. earned 1000 total points
ID: 39789920
Try this
   Dim RS As DAO.Recordset
        Set RS = CurrentDb.OpenRecordset("tblReady")
            with RS
                 .AddNew
                 !Bay = Forms!frmPlanted.ListBayQty.Bay
                 !ReadyQty = Forms!frmPlanted.ListBayQty.ReadyQty
                 .Update
            end witn
      RS.Close

set RS= Nothing

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 39789930
What is he need for this?

I mean, ...there is a way to do this as you ask, ...

But if you state your ultimate goal, we may be able to provide a more efficient method...

For example, it should be far easier to insert the listbox "source" to a table.

But again, if the listbox source is already a table/query, ...what is the need to export it to another table?

JeffCoachman
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

656 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