473,427 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,427 software developers and data experts.

VBA Update Subform

21
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.[NameOfYourSubformControlHere].Form.RecordsetClone
.AddNew
!SomeControl = SomeValue
!AnotherContorl = AnotherValue
'etc.
.Update
End With

http://www.thescripts.com/forum/thread190259.html

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 1514
Scott Price
1,384 Expert 1GB
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>Editor 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
Hi Scott..

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

Regards
Susan
Aug 30 '07 #3
Scott Price
1,384 Expert 1GB
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
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...
1
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'...
0
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
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...
1
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...
1
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...
1
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...
6
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...
0
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.