473,786 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Subform displaying existing record won't display new record

63 New Member
I have a subform which is bound to a query which will display records using an ID# supplied from a listbox in the parent form.

That same subform is also used to create new records using the following code in a "New Record" commandbutton:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.GoToRecord , , acNewRec
Both functions work fine. However, if I have a selected record displayed, and I click the "New Record" button, it does not move to a new record. It just stays on the selected record and any edits I make affect that selected record.

Any help you can provide is appreciated!
Jan 21 '09 #1
21 7162
puppydogbuddy
1,923 Recognized Expert Top Contributor
If your button is executing from the main form, I believe you have to set focus on the subform to execute the new record command for the subform.
Try your code this way:
Expand|Select|Wrap|Line Numbers
  1. Me.YourSubformControlName.Form.SetFocus
  2. DoCmd.GoToRecord , , acNewRec
  3.  
Jan 22 '09 #2
postman
63 New Member
Thanks for the suggestion, puppydogbuddy. I tried it, but I get the following error:

Run-time error '2449': There is an invalid method in an expression.

It highlights the line with the "SetFocus" method for the form. I tried various approaches for the SetFocus, but they all end in the same error.

Any idea why?

Thanks for your help!
Jan 22 '09 #3
puppydogbuddy
1,923 Recognized Expert Top Contributor
oops, I forgot to set focus on a control on the subform source object(the form embedded in the subform control).

See this link: How to select controls on a subform with setFocus method in Access 2002
Expand|Select|Wrap|Line Numbers
  1. Me!YourSubformControlName.Form![ID].SetFocus 
  2. DoCmd.GoToRecord , , acNewRec 
  3.  
Jan 22 '09 #4
postman
63 New Member
Thanks for the info. It wasn't working, but after looking at the table, I found that new records were being created, but the bound fields in the subform weren't clearing to display the new record--they were still displaying the selected record.

Ideas?

Thanks!
Jan 22 '09 #5
puppydogbuddy
1,923 Recognized Expert Top Contributor
Is the subform's "allow additions" property set to "Yes"?
Jan 23 '09 #6
NeoPa
32,578 Recognized Expert Moderator MVP
@postman
Perhaps you need to requery the subform after the item has been added.
Jan 26 '09 #7
postman
63 New Member
I just realized what the problem probably is. The subform is bound to a query which uses a listbox value as the criteria. If a record is selected in the listbox, the subform is going to display those contents regardless of what's happening in the table.

I'll try a few things on that track and post the results...or more questions.
Jan 27 '09 #8
NeoPa
32,578 Recognized Expert Moderator MVP
That's about the size of it. The requery should help ;)
Jan 27 '09 #9
postman
63 New Member
The simplest fix to the problem was just changing the subform's "DataEntry" property to True when the "Create New Record" button is clicked, and to False when the "Display Records" button is clicked.

But that created the opposite problem, now:
If I go first to Display Records, it will display the selected records fine.
But if I first Create a new Record, then go to Display Records, the subform won't display the selected record from the listbox.

(The subform's recordsource is a query that uses the listbox value as criteria. The Listbox's click event does requery the subform.)

Not sure why this is happening.
Jan 27 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
8410
by: Carl | last post by:
I have a main form with navigation buttons on it and a label showing for example Record 1 of 15 using recordsetclone on it and eveything works fine. When I move through the records the record number changes fine. Within this main form I have a subform detailing distribution records for the contact (main form is based on this) that also has navigation buttons and a label showing Distribution 1 of ##. This is where the problem lies. The...
25
10267
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
6
5477
by: Tim Marshall | last post by:
Here's the situation. A form, frmSetUp, with a subform control called subExplain with a source object form frmSetUpSubDefineSides. The source object is a bound form, displaying a few records, no edit, adds, filters, etc, are permitted on the subform. An add or edit button on the subform is clicked opening an unbound form, frmSetUpSideAdd, (populated with values from the above subform if this is an edit of an existing record) for data...
4
7018
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which means showing all the data put in previously (ie showing this via the requery and the continuous...
5
5260
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It works except that when I flip through the names it populates the parent form with the name of what ever...
5
2255
by: Thelma Lubkin | last post by:
I have a form/subform with the common one-to-many relationship. The form allows user to display records and move to other records via the selector, to add,delete, and edit them, with the related records displayed in the subform going along for the ride. The parent form's recordset has fields string integer COLORNAME CLASSSIZE and a few more that aren't relevant here.
20
10828
by: Robert | last post by:
Need some help to stop me going around in circles on this one.... Have a nested subform (subform2) which simulates a continuous form for the record on the parent subform. Subform2 has rows of either an option button plus two text fields or a checkbox plus two text fields Am wanting to save the user entries into an underlying table. Tag property for each option button, check box or text field has the value of the key
10
1729
by: sara | last post by:
Hi - I am developing a simple app, and just found a problem that I can't fix after 4 hours of trying. I display a list of customers, and the user chooses one and displays "orders". The frmOrders displays correctly, with the subform - frmOrders_sfrmCustInfo - on top that is correct. The subform displays cust info - name, address, phone. Name is from a function that takes
14
2350
kcdoell
by: kcdoell | last post by:
Hello: I have a form (Default view =single form) with a subform (Default view =continuous forms) embedded into it. In the form I have three controls that display the Division, Working Region & Credit Region. The subform displays the data/records. The record source for both my form and subform is driven by a query, which is the way I filter the records that the end user will see via another form I created. Everything is working fine but...
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4066
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.