Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Expert One-on-One Access Application Development
This is the forum to discuss the Wrox book Expert One-on-One Microsoft Access Application Development by Helen Feddema; ISBN: 9780764559044
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Expert One-on-One Access Application Development 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 August 13th, 2004, 09:13 AM
Registered User
 
Join Date: Aug 2004
Location: Eden Praire, MN, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error 3021 - No Current Record

Hello,

I recently bought "Expert One-on-One Access Application Development" by Helen Feddema, and I am stuck in chapter 2, pg. 53. I have two tables; tblVendors which is the "One" side of the relationship, and tblVen_Addrs, which is the "Many" side. I created a main single-form based on tblVendors and a subform based on tblVen_Addrs. Following the examples in the book, I created an unbound control, set its rowsource to tblVendors and then wrote the code for the cboSelect_AfterUpdate() as listed on page 53.

However, when I switch to Form View, and attempt to choose a record by using the cboSelect combo box, I get an error message through the "On Error GoTo ErrorHandler" code, which displays the message "Error: 3021 Description: No Current Record". The number changes in the combo box, but all the other fields remain blank.

Also, I'm not sure what I did, but now for some reason I can't see my subform anymore. It is there in design view, but when I switch to Form view, its gone. I checked the properties & made sure that Visible = True; but I don't know what else could be causing this.

Please help!!!

Thanks!
Reply With Quote
  #2 (permalink)  
Old August 13th, 2004, 04:23 PM
Authorized User
 
Join Date: Jun 2004
Location: Cumberland, MD, USA.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just to see if I have learned anything from reading parts of this book (and many others) I tried to recontruct the database that you made. I created a tblVendor (Fields: VendorID, Vendor) and a tblVendor_Addrs (Fields: Vendor_AddrsID, Vendor_Addrs, VendorID). I created a relationship to link the two tables (linked by VendorID). I created a form bound to tblVendor and added a subform bound to tblVendor_Addrs.

At this point I was able to open the form and add data to populate the two tables. NOTE: Once I added some data, I could move from Vendor to Vendor in the main form and the data in the subform changed appropriately to display the linked Vendor_Addrs data. Does your form/subform work like that?

Then I added cboSelect, whose record source was tblVendor bound to column 1 (VendorID). I modified the properties of cboSelect to display 2 columns, but I set the width of the first column to 0. Now cboSelect should display the Vendor (text), but hide the VendorID. I added the cboSelect_AfterUpdate code shown on p.53. I deleted the strSearch expression for the text ID and edited the strSearch expression for numeric ID to read:

strSearch = "[VendorID] = " & Me![cboSelect]

When I open the main form and selected a Vendor from cboSelect both the main form and the subform changed to display the appropriate data. The bottom line that this seems to work OK.

You stated that when you attempted to choose a record using cboSelect the number changed in the combo box but all the other fields remained blank. Assuming that you have some data in the tblVendor and tblVendor_Addrs, when you open the form you should see data for the first record in tblVendor displayed on the main form and the appropriate data from tblVendor_Addrs displayed in the subform and the cboSelect text field should be blank. Get your main form/subform workinh correctly without cboSelect and then add cboSelect and its associated code. BTW, the Access control wizard can be used to add a combobox and VBA code very similar to that shown on p.53.

I hope this helps. But if you are still having trouble, I would be willing to send you the simple database that I created. Let me know.

Terry Waltz
Reply With Quote
  #3 (permalink)  
Old August 16th, 2004, 03:30 PM
Registered User
 
Join Date: Aug 2004
Location: Eden Praire, MN, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello tlwaltz,

I'm not sure what I've done wrong, but I wrote some code in the Form_Open Event to to display the record number:

Code:
Private Sub Form_Open(Cancel As Integer)
    MsgBox (Format(Me.CurrentRecord, "0"))
End Sub
When I open the form, I get the number 0. This does not seem right to me. It seems like the form is not linking to the appropriate table, or is not moving to the first record when opened even though the correct table is listed in the form's RECORDSOURCE property. I think this may be why I'm not seeing any subforms showing, because the form doesn't have a record selected on open. Do you have any suggestions?

Also, I have purposefully disabled the form's NavigationButtons property to prevent users from moving through the database without using the proper methods. And when I click on the cboSelect combo box, I see a drop down list of all the correct record numbers, its only when I try to select one that I get the error message.



Reply With Quote
  #4 (permalink)  
Old August 17th, 2004, 07:05 AM
Authorized User
 
Join Date: Jun 2004
Location: Cumberland, MD, USA.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The secret to OOP is knowing what the events are, knowing the sequence in which the events are triggered, and understanding what tasks are commonly performed in a particular event.

I think that within the Form_Open event you will get the Me.CurrentRecord=0. Put a statement like

intCurRec=Me.CurrentRecord

in both the Form_Open (add a breakpoint to this line of code) and the Form_Load events. Open the form and step thru the code. Within Form_Open Me.CurrentRecord will equal 0, but withing Form_Load Me.CurrentRecord will equal 1.

I'd start over recreating your form. Go step by step and make sure that each step works OK as you go. First, create the main form and verify that you can display the data in a record and that you can move from record to record. Then I'd add the subform and verify that the data in the subform is synchronized with the data in the main form. Once all of that is working correctly, I'd add the combobox to navigate to a specific record. Then the last thing I would do, once everything is working OK, is remove the navigation bar.

I am curious as to why you are displaying the record number in the combobox. Are you trying to find a particular record using the record number? Usually the combobox is used to find a particular record based on the key field. Record numbers will change when you delete records (record numbers also will change if you filter or order the data).



Terry Waltz
Reply With Quote
  #5 (permalink)  
Old August 17th, 2004, 10:25 AM
Registered User
 
Join Date: Aug 2004
Location: Eden Praire, MN, USA.
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again,

Well, I ended up remaking the form from scratch and now everything works fine...?!?! Don't know why, but it must have been a glitch.... Here's to hoping I don't have any more... =)

Thanks for the help!!!

Reply With Quote
  #6 (permalink)  
Old October 2nd, 2004, 03:26 PM
Authorized User
 
Join Date: May 2004
Location: Kerhonkson, NY, USA.
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Terry Waltz's advice was correct. I suspect the problem had to do with the field used for synching the record.

Helen Feddema
Kerhonkson, NY
hfeddema@hvc.rr.com
http://www.helenfeddema.com
Read Woody's Access Watch
http://www.woodyswatch.com/waw/
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
Error msg 3021 MathLearner VB Databases Basics 1 May 17th, 2007 07:41 AM
Current Record Number Base VB How-To 1 December 7th, 2005 05:26 PM
"no current record" error in DAO code Loralee Access 6 October 13th, 2005 12:50 PM
runtime error 3021-no current record togs74 Access 1 July 30th, 2005 02:10 AM
Print current record vladimir Access 2 September 10th, 2003 11:53 PM



All times are GMT -4. The time now is 10:12 PM.


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