Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > BOOK: Access 2003 VBA Programmer's Reference
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 3rd, 2008, 02:22 PM
Registered User
 
Join Date: Jun 2007
Location: Hamilton, ON, Canada.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to fcortes
Default How to bind Recordset to an Access Subform in VB?

Hi
background:
I'm new to VB (I've done some programming in C#)...

Type of Database being developed:
Access 2003 (Student Grading System: student info, subjects, levels,
classrooms, teachers, indicators and achievements(last 2 is what is evaluated: meaning students either get approval on the indicator or not, and several indicators compound an achievement), etc)

What I'm currently developing:

I'm working on an Access 2003 form to assign indicator approval to a list of students that are part of classroom group. The form should show the following:
1. Text fields: Class, subject, achievement and indicator being graded (done and working)
2. A combolist populated with classrooms according to the class (done and working)
2. a button that would take the classroom selected (from the combolist) and after is clicked, a "table/Grid" with students from that classroom selected (studentID, name, lastname AND a Approval column approval to indicate if the student passed the indicator (check mark) or not (no check mark). This table comes from recordset generated dinamically
3. a button that should update a table with the information from the "table/grid" Once the "table" shows the students who passed (have the check mark on the approval column).

Problem:
I'm stuck on number 2:
WHAT I HAVE:
I have the recorset ready with the info I need (studentID, name, lastname and approval) with some sample records to work with. (this record set gest generated and populated fine)
WHAT I DON'T HAVE (PROBLEM):
I need to bind this recordset to some datagrid/datasheet subform that could show the information from the recordset I have ready.
WHAT I HAVE TRIED:
1. I have tried to bind an unbound subform from VB code but it just wouldnt let me:
me.UnboundSubform.SourceObject = recordset ->> I get an error saying object property not supported or something like that.
2. On some thread I found someone suggests that I need to bind the subform and change the recordsource dinamically from VB (I couldnt figure out how to do that, as:
Me.UnboundSubform.Form.RecordSource = recordset --->>.. would also give an error
3. another thread suggested to bind the subform to a table and in vb add the records from the recordset onto the table but the problem is I need to pupulate the table after clicking on the button so the table needs to have records added dinamically. This doesnt happen that way if the subform is bound from the beginning. what I get when I tried this is a subform that shows records as the parentform is loaded and not when the button on the form is clicked.

MY THOUGHTS ON POSSIBLE SOLUTIONS:
1. Is there a datagrid control in Access 2003 or something similar? in VS this would've been the most convenient method to do it.
2. Is there an event I could work with on the subform that I could manipulate so no binding takes place until user clicks the button so records are added dinamically from the recordset generated?

Thanks for your help! (I've been stuck for 2 days already)



Reply With Quote
  #2 (permalink)  
Old March 1st, 2008, 08:39 PM
Registered User
 
Join Date: Jun 2007
Location: Hamilton, ON, Canada.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to fcortes
Default

I couldnt do what I was planning on doing, so what I endedup doing is creating a table dynamically through code and I ended up opening another form that shows that table created dynamically. so in other words the subform that I wanted to populate after clicking a button can't (or I least I couldn't) be populated on the same form. I had to open another form and bind that dynamically created table to that new subform that opens to the click of that button.

this my sloppy code.. if you care to see it.

'reference to current database
    Dim copesalTest As DAO.Database
    Set copesalTest = CurrentDb ' Get a reference to the current database

    'set BOF on rsFinal to start adding records to temp table from the beginning
    rsFinal.MoveFirst

    'delete any previous table created with then name of ListaAlumnosPorSalon IF EXISTS!!
    dbsTableDelete ("ListaAlumnosPorSalon")


    'create a brand new table called ListaAlumnosPorSalon
    crtTable ("ListaAlumnosPorSalon")


    'add records from rsFinal to ListaAlumnosPorSalon table
    Dim tablaAlumnos As DAO.Recordset
    Set tablaAlumnos = copesalTest.OpenRecordset("ListaAlumnosPorSalon") ' Get a reference to the table ListaAlumnosPorSalon

    Do Until rsFinal.EOF = True
    tablaAlumnos.AddNew
    tablaAlumnos("Codigo").Value = rsFinal.Fields(0).Value
    tablaAlumnos("Apellido").Value = rsFinal.Fields(1).Value
    tablaAlumnos("Nombre").Value = rsFinal.Fields(2).Value
    tablaAlumnos("Calificacion").Value = rsFinal.Fields(3).Value
    tablaAlumnos("Indicador").Value = txtIndicadorID
    tablaAlumnos.Update
    rsFinal.MoveNext
    Loop

    'Open form with students and approval temp table "listAlumnosPorSalon"
    Dim stDocName As String

    stDocName = "ListaAlumnosPorSalon"
    DoCmd.OpenForm stDocName, , , , acFormEdit



     'Disconnect
     Set con = Nothing
     'con.Close


    'free up memory
   rs.Close

    'Set rs = Nothing
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind Tree View to MS Access table using VB bonekrusher ASP.NET 2.0 Basics 1 December 22nd, 2006 12:42 PM
bind recordset to field ibgreen SQL Language 0 October 24th, 2006 12:48 PM
Bind datagrid to recordset MAntis_sg Classic ASP Databases 0 May 15th, 2006 07:31 AM
How to bind data from a recordset to a combobox? wayne62682 Access VBA 6 April 2nd, 2006 08:45 PM
How to bind text box to recordset fields? cici VB How-To 2 December 1st, 2003 02:10 AM



All times are GMT -4. The time now is 06:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.