473,382 Members | 1,733 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,382 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 2017
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.