473,395 Members | 1,936 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,395 software developers and data experts.

Creating a Default Value for field in a subform when a field in the subform & form...

2
Problem: Creating a Default Value for a field in a subform when a field in the subform & form match.

I'm trying to create a payroll database for a small home business that I have that has had (and hopefully will continue to have) lots of growth.

I have created a Transaction table to hold the hours, date, location of work (as the employees work at various locations), pay rate, and employee id. the employee id field has a one-to-many relationship with my employee information table where the employee name, address, and phone number is stored.

I don't think I can create this type of default value in the transaction table, so I've been trying to create it in the subform, but to no avail.

I saw the post http://www.thescripts.com/forum/thread634973.html that discussed a very similar problem and I tried to utilize the code that was placed there, but even after replacing the necessary fields, it still isn't working.

As all the payroll period entries (transactions) will be in one table, the default value for the pay rate needs to be the last pay rate for the same employee id.

Any suggestions?

THANKS IN ADVANCE!
May 19 '07 #1
4 2019
NeoPa
32,556 Expert Mod 16PB
If you go through the other thread and decide that you would like to use the method that I proposed there, then you'll need to tell me what you've managed to get working or, if nothing, what you tried and what result you got.
I'm psychic, but not THAT psychic ;)
May 19 '07 #2
rczuba
2
First of all, sorry for breaking the rules. This is my first time ever using a forum, so I'm trying to assimilate.

Second, I'm not a very advanced coder, so I may be making tons of stupid mistakes. Any help would be appreciated. This is what I have:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Rate_AfterUpdate()
  2.  
  3.     If Not IsNull(Me.Rate) Then
  4.         Recordset.Edit
  5.         strSave = Me.Rate
  6.         RunCommand acCmdSaveRecord
  7.     End If
  8.  
  9. End Sub
  10.  
  11.  
  12. Private Sub Last_name_AfterUpdate()
  13.  
  14. DoCmd.RunCommand acCmdRefresh
  15.  
  16. End Sub
  17.  
  18. Private Sub Last_name_AfterUpdate()
  19.     ' Find the record that matches the control.
  20.     Dim rs As Object
  21. Set rs = Me.Recordset.Clone
  22.     rs.FindFirst "[Last Name] = " & Str(Nz(Me![Last Name], 0))
  23.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  24.  
  25. End Sub
  26.  
  27.  
  28. Private Sub First_Name_AfterUpdate()
  29.  
  30.     ' Find the record that matches the control.
  31.     Dim rs As Object
  32.  
  33.     Set rs = Me.Recordset.Clone
  34.     rs.FindFirst "[First Name] = " & Str(Nz(Me![first Name], 0))
  35.     If Not rs.EOF Then Me.Bookmark = rs.Bookmark
  36.  
  37. End Sub
  38.  
  39.  
May 23 '07 #3
NeoPa
32,556 Expert Mod 16PB
Having the code posted may well prove useful later on, but I still need answers to my earlier questions. To whit :
  1. Do you want to use the method I proposed?
    I can assume a yes to A.
  2. What (if anything) is working now?
  3. Where things do go wrong - how do they? What error message are you getting if any? Does it stop on a particular line? If so, which one?
I like to think I can help, but I won't be doing it for you. I will work with you to help discover and fix your problems.
Remember also, that I know only what you tell me.
May 23 '07 #4
NeoPa
32,556 Expert Mod 16PB
As a starter, I'll point out some potential problems with the code I see.
  1. Line 5 - strSave = Me.Rate
    strSave is not defined anywhere I can see.
  2. Lines 22 & 34 need quotes (') around the values.
I shall await your response to my earlier questions.
May 23 '07 #5

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

Similar topics

4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&" when it gets used as a querystring in the url EG: ...
3
by: Bruno Luis | last post by:
Hello I'm using A97 and i'm having some trouble with creating a recordset with data from two different databases. I connect to a remote database and make this data the default source for my...
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...
1
by: Mike | last post by:
I have a form that has an embedded subform (Datasheet View) that are linked based on a 1-many ID field. I have a field (SET) in my embedded subform that I want to Autoincrement starting with...
4
by: aflat362 | last post by:
If you look at this page on relational database design: http://r937.com/relational.html And scroll down to the "Many-to-Many Relationships" Section you will see a common database structure. ...
3
by: solargovind | last post by:
Hi, I am New to this forum. I need steps that i do in creating subform. In main form, i have one table fields like vendor,account,due amount,balance amount and Requisition_id which is...
4
by: Whasigga | last post by:
Hi I've created a form that has 7 subforms. It is the same subform, bound to a table, just repeated. This form represents a week, and each subform is used to enter in data for each day of the...
4
by: JHite | last post by:
I am using Access 2003 on Windows XP. This is a simple database that contains “tblStaffers” containing names of the office staffers, “tblProjects” containing names of the office projects, and...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...
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,...

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.