473,404 Members | 2,178 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,404 software developers and data experts.

Why when I dirty a subform does the default value of a control on the subform change?

269 256MB
I have a form (frmEmployees) with one control (Name) and on it is a subform (subHours) with 4 fields/controls where I can put some data, and one very important field (HoursName). HoursName is set to the default value of the only field on the main form.

My desire is to scroll through our list of employees and enter hours for each one. The subform will contain all the data to save (the employees name and the hours each one worked). I have linked my master/child fields.

The default value of HoursName is set as [Forms]![frmEmployees]![Name]. (I learned from experimenting ! does not equal . in this phrase.)

Anyway, I thought I was having great success. When I open the form, the first employee's name shows up on the main form and in the subform. I enter the hours. It saves to the table. BAM!

Then I use my arrows on my main form to scroll over to the next record, and the second employee name appears correctly on the main and subform. BUT when I dirty the form by typing into any field, the [HoursName] on my sub form changes from the name of the employee to "frmEmployees". And it does this on every record afterwards.

Can someone offer me any tips? (I have already played with different combinations of Enabled and Locked with no success.)

Thanks in advance!!
Sep 4 '13 #1
5 1734
jimatqsi
1,271 Expert 1GB
DanicaDear,
What events have you programmed code to handle? When you say "It saves to the table. BAM!" I'm wondering if BAM! is right away, as in it is executing an "OnChange" event, or when you tab out of the field you edited ("AfterUpdate" event) or when you click a save button or something else.

Seems to me there may be some code we need to see.

Jim
Sep 4 '13 #2
Rabbit
12,516 Expert Mod 8TB
Name is a reserved keyword in Access, you should never use it as the name of a field, table, query, etc. While it won't stop you from using it, it will cause unpredicted behavior such as this. You may intend for it to pull the value of a control named name on your form, but instead it is pulling the property named name on your form. You need to rename everything that is using a reserved keyword.

After doing this fix. You should be aware that you may not even need to set a default value for your HoursName field. If I understand what you have said, HoursName is your child field that is linked to the master field. In this setup, the value will be populated automatically due to master/child relationship, there's no need to populate it again.


[Z{Edit- 20130904@14h43C}
Access 2007 reserved words and symbols
AllenBrowne- Problem names and reserved words in Access{/Edit}]
Sep 4 '13 #3
DanicaDear
269 256MB
Jim,
There is no code, at least none I have put in. I only say BAM because I have tried so many different things to make this simple thing work and so when I finally did get close I was just so excited.

Rabbit,
I think you may be on to something. I will apply your suggestions and report back. I initially didn't have the extra field because I too thought the data should populate from the first field. By when it did not I just figured I had screwed something up....yep.... LOL

Thank you both so much. I love Bytes!!! Will report back soon.
Sep 5 '13 #4
DanicaDear
269 256MB
Yes, when I took out the "Name" reference everything worked. Ooohh that cost me some hours. LOL.

Thanks so much!!
Sep 9 '13 #5
Rabbit
12,516 Expert Mod 8TB
No problem! Good luck with the rest of your project.
Sep 9 '13 #6

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

Similar topics

2
by: Terry Bickle | last post by:
Please forgive me for using the wrong term here or there. I'm an old Excel 4 macro guy who didn't convert to VB and I'm tinkering with an Access 2000 DB. I'm sure there is a simple Access 101...
2
by: CSDunn | last post by:
Hello, I have a field called 'TestGrade'in a subform called 'frmSelectByTestSub'that I need to assign a default value to, and the value needs to be an integer value that is exactly the same as the...
2
by: brenda.stow | last post by:
error msg " An error occured while referencing the object. You tried to run a visual basic procedure that improperly references a property or method of an object" This msg occurs everytime I add a...
3
by: tlyczko | last post by:
I have Stephen Lebans' RichText control on a subform, which is bound to a memo field. The only editable control on this subform is the rich text control for the memo field. When the main form...
9
by: PeterWellington | last post by:
I have a column in a data table that stores enum values and assigns a default value: Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday When I...
6
by: carmela_wong | last post by:
Hello all, I am trying to set the default value of a combo box to "USA" which does not work although I have entered this in the Default Value property of the control. The combo box shows the...
1
by: nlsmith326 | last post by:
Greetings! Was wondering if anyone out there had any suggestions for setting a default value. I have one main form w/ tabs & subforms. What I've been trying to do (unsuccessfully) is set a...
30
by: DanicaDear | last post by:
I will search for on frmCustomers. When I find the customer, I click a button btnShowOrders and it opens frmOrders with subfrmOrderDetails2. (I'm having trouble grasping the previous sentence...
11
by: hannoudw | last post by:
Hi I have a form that contains 2 text boxes and a subform contain the Invoice details. the 1st text box is txtInvoice and its bound to Invoice_number in the invoice table , it's an auto-number. and...
1
by: Anthony Herrera | last post by:
CREATE TABLE CP_INTFDC (ID_ACQ_IIC number(11,0) not null, ID_FWD_IIC number(11,0) not null, ID_INCOMING_TIMER number(6,0) DEFAULT 600 NOT NULL, ID_OUTGOING_TIMER ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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...

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.