473,569 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VBA Update Subform

21 New Member
Good Day, I was currently browsing on ways to update records within a form to a subform. and noted the following article by Alan Brown on how to make use of the

With Me.[NameOfYourSubfo rmControlHere].Form.Recordset Clone
.AddNew
!SomeControl = SomeValue
!AnotherContorl = AnotherValue
'etc.
.Update
End With

http://www.thescripts. com/forum/thread190259.ht ml

I am currently usting the above menioned as folllows and works perfect to update my subform

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdAddSkills_Click()
  2. With Me.[SkillsList].Form.RecordsetClone
  3. .AddNew
  4. !PersonID = MeID
  5. !SkillID = Me.AddSkills
  6. .Update
  7. End With
  8. End Sub
It does however not seem to actually updat the records If i go into another form to view the added data it is still the same data as before. Does the above meniotioned actually append the data to the records.
Or am i missing something.
Aug 29 '07 #1
3 1523
Scott Price
1,384 Recognized Expert Top Contributor
Did you copy and paste your code in? If not, is line 4 a typo?
Expand|Select|Wrap|Line Numbers
  1. !PersonID = MeID
If you are trying to refer to a control on your form named ID, the correct code is Me.ID or Me!ID. What you have (assuming you've not declared this as a variable and populated it elsewhere) is an implicitly declared variable named MeID that contains nothing, therefore your PersonID will be populated with nothing.

A VERY good coding practice is to require explicit declaration of variables by enabling the Option Explicit in your editor window by clicking on Tools>Options>E ditor and check the box Require Variable Declaration (and typing it into modules that don't have it). This just means that you cannot misspell something in your code, because when you compile, Access will check and give a compile error if the variable has not been declared in the proper way.

Otherwise you can type anything in you want (within some limits of course) and Access will assume that you are declaring a variable and will give it the type of Variant. This can wreak havoc in your code!

Regards,
Scott
Aug 29 '07 #2
natural
21 New Member
Hi Scott..

Thank you very much for your help. Working perfectly..

Regards
Susan
Aug 30 '07 #3
Scott Price
1,384 Recognized Expert Top Contributor
Hi Scott..

Thank you very much for your help. Working perfectly..

Regards
Susan
Glad to hear it's working!

Regards,
Scott
Aug 30 '07 #4

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

Similar topics

0
2271
by: JJMM | last post by:
Hi, I have a form with a large number of subforms inside it (around 20 subforms), There is the possibility of filtering the data using a pop-up form that create/change a query (all the subforms are linked to that query), Once that I create/change the query, Is there any easy way to update all the 20 subforms on the fly??. Normally I use...
1
3824
by: noone | last post by:
I'm making a sales order database similar to Northwinds but with a slightly different form. The tables are the same. The 'Sales Orders' form has a 'Line Items' subform. I've added a 'Add Item' button to the master form 'Sales Orders'. Clicking the button will bring up a popup window'Search' ( a continuous form). A combo box on the...
0
1749
by: Kaspa | last post by:
Hello, I have been trying to goto the next record once I update the subform. anybody knows how I can accomplish this. Thanks in advance. Kasparov
1
1999
by: Lynx101 | last post by:
Hi, Hope you can help? Senario: I have an access frontend and backend database. All is working fine when using MS Access for both. Problem: I have created a backend SQL database in preparation to replace the Access backend database. After I link (via ODBC) to the new SQL tables one of my subforms no longer allows me to add records.
1
1822
by: bbatson | last post by:
Hello, I have two tables that are feeding a form/subform relationship. The first table, called "Tbl_Projects" lists a variety of projects taken on by a department. A second table called "Tbl_Project_Codes" (the "many" in the one-to-many relationship) details various codes that are associated with the projects. For example, a project may be...
1
4486
by: maciejfr | last post by:
Hello everyone, My problem is updating Subform filter by onchange event in one of main form field I've got following: Me!.Form.Filter = " = "" N "" OR ( = ""T"" AND notanr = " & Me!nrnoty & ")" Forms!frmNOTAWY.Form!.Requery
1
1995
by: Rosy | last post by:
I have a form "A" that is set on table vessel names. I have subform "B" that is set on table vessel info. I want form "B" to update based on what vessel I choose in form "A". I know this is an easy one. :)
6
2285
by: meek7 | last post by:
I program vba in excel but am having quite a few problems with access.I have a query that i type quantites into after i take orders which then calculates prices. i am trying to enter that data by scanning a barcode into a textbox. i was able to do this for a table but how is it done for a query? thanks for the help.
0
1244
by: FrankB63 | last post by:
I have a pivottable built off a query that is used to populate the listboxes, 1 for location 1 for category. Those fields are included in the query to generate the sums based on the age of each record. ie, <15, 15-20 and >20 days old. After selections made in listboxes, I am able to generate a detail page that allows users to be able to...
0
7619
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...
1
7681
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
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...
0
5228
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...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
950
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...

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.