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

Subform data entry is set to YES but it displays all records on refresh

106 100+
Hi,

On a default startup form (switchboard) I have a combobox in which one selects the username (bound to StaffNum) and clicks OK to open up the mainform.

On the mainform I have a data entry form that has its DATA ENTRY option set to YES.
for StaffNum field, I set the Default Value as
Expand|Select|Wrap|Line Numbers
  1. =[Forms]![Switchboard]![cboStaffNum]
initially the form opens up as data entry, but after inserting new records, and hitting the refresh button, all records are displayed in this subform.

Refresh Button Code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdRefresh_Click()
  2.  
  3.     Me.Accounts_Totals.Requery
  4.     Me.MMQ_DataEntry.Requery
  5.     Me.lstTotals.Requery
  6.     Me.lstCashinHand.Requery
  7.     Me.lstAccountBalance.Requery
  8.     Call CalculateTotals
  9.  
  10. End Sub
  11. ---
  12. This routine adds up figure from a column in listbox
  13. Public Sub CalculateTotals()
  14.  
  15.     Dim varOutTotal As Currency
  16.     Dim varInTotal As Currency
  17.     Dim varRow As Integer
  18.  
  19.     For varRow = 1 To (Forms!Totals_By_Date!lstTotals.ListCount - 1)
  20.         varInTotal = varInTotal + Forms!Totals_By_Date!lstTotals.Column(1, varRow)
  21.         varOutTotal = varOutTotal + Forms!Totals_By_Date!lstTotals.Column(2, varRow)
  22.         Next
  23.  
  24.         Forms!Totals_By_Date!txtPaidOutTotal = varOutTotal
  25.         Forms!Totals_By_Date!txtPaidInTotal = varInTotal
  26.  
  27.         Forms!Totals_By_Date!txtBalance = varInTotal - varOutTotal
  28.  
  29. End Sub
  30.  
for the STAFFNUM Field, if leave the Default value as blank or I set it to number as 1,2 or 3 etc, then the database works fine.

I am not sure as to why I am facing this problem.

Your help is appreciated.
Aug 3 '12 #1
2 2248
twinnyfo
3,653 Expert Mod 2GB
tasawer,

After your Refresh, do you want to only display the records that relate to cboStaffNum? If this is the case, you might want to simply add the following code at the end of your cmdRefresh Sub:


Expand|Select|Wrap|Line Numbers
  1.     Me.Requery
  2.     Me.Filter = "StaffNum = " & [Forms]![Switchboard]![cboStaffNum]
  3.     Me.FilterOn = True
  4.  
That assumes Switchboard is still open. If not, you would have to save the StaffNum in a variable, then filter by that variable.

Hope this works. If this is not what you are trying to do, please explain.
Aug 3 '12 #2
tasawer
106 100+
after reresh, The dataentry subform should go to blank, ready to take more records, but instead it displays all the records related to cboStaffNum ID.

If I force the field StaffNum to e.g.'2', then the whole system works fine.
Aug 3 '12 #3

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

Similar topics

5
by: Nancy | last post by:
I have two tables: TblCourse CourseID CourseName TblClass ClassID CourseID ClassDate
5
by: JJ | last post by:
I have a MainForm/subform1/subform2 setup that I thought was working but maybe I just hadn't tested it enough or broke it as I added more features. The database has 2 main tables: Companies and...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
1
by: KC | last post by:
Hello, I am using Access 2002. WinXP, Template from MS called Orders Mgmt DB. I have tweaked this DB to work for our small co. It has worked pretty well up until I made the mistake of deleting...
5
by: lottaviano | last post by:
I am using Access 2002 and have two tables (Main and Actions) linked (in Relationships) on one field "CAL_ID" (primary key in Main Table). Main Table is a list of equipment. Actions Table lists...
3
by: bosmatthews | last post by:
I have a main form with a subform and a second subform nested to the first subform. The data entry property for all three forms (main, subform and sub-subform) is set to "yes" because I am intending...
20
by: hippomedon | last post by:
Hello everyone, I'm looking for some advice on whether I should break the normalization rule. Normally, I would not consider it, but this seems to be a special case. I have created an...
3
jhowells28
by: jhowells28 | last post by:
I am using Access 2003. I have built an invoice entry form to enter invoices. It has a subform for the invoice detail. Everything works, but when I enter purchase order invoice information on the...
0
by: Tyler | last post by:
Made a data entry form which is a subform. I made a continuous form that displays everything entered through the data entry form. The data entry form displays all of the records. This doesn't...
1
by: AlisonP | last post by:
Hi, I am a relatively new Access programmer, but have programmed computers in Fortran and done complex modeling for years. Am learning quickly, and have managed to figure everything out so far, but...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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...

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.