Best Place For Code
Oct 29, 2006
Hi again, This might be a simple answer, but I have tried several event properties, the last in the OnCurrent of the main Form. But most of the calcs work most of the time, and occassionally I get an 'Error 2001'. I have a couple of years VBAing, so still a teenager?? I am curious as to wether I am placing the calcs in the right event. I really only want them to do the calcs when the leave tab is selected (see enclosed image) and/or if a new employee record is navigated to. I will also attach code of calcs. If it needs to go into the Tab control what is the best event?
NB pink fields on form are visible=No and for troubleshooting
Coding:
' Run Calcs here for Leave other than Sick Leave.
If IsNull(EmpStartDate) Then
DaysWorked = 0
Else
DaysWorked = DateDiff("d", EmpStartDate, Now)
End If
' Calc number of days between Employee Start Date and Now
TotalLeaveAlloc = DaysWorked * (Me!AnnualLeaveDue / 365)
' Divide Allocated days by 365 and multiply by number of days worked
If IsNull(DSum("[DaysTaken]", "[qryLeaveRecords]", "[LeaveType]<>'Sick' And [tblEmployees]![EmployeeID] = [tblLeaveRecord]![EmployeeID]")) Then
TotLeaveRecorded = 0
Else
TotLeaveRecorded = DSum("[DaysTaken]", "[qryLeaveRecords]", "[LeaveType]<>'Sick' And [tblEmployees]![EmployeeID] = [tblLeaveRecord]![EmployeeID]")
End If
' Calculates the number of leave days taken from leave records in database based on qryLeaveRecords
' Used IsNull to check if there are no records found - set calc result to zero
Me.Taken01 = TotLeaveRecorded 'visible option = no
' Display this on screen
If IsNull(Me.LeaveAccrued) Then
LeaveBalance = TotalLeaveAlloc - TotLeaveRecorded
Else
LeaveBalance = TotalLeaveAlloc - (TotLeaveRecorded + Me.LeaveAccrued)
End If
' Check if there is any Accrued Leave [reduces the need to load historical Leave Records] and subtract them
Me.Bal01 = LeaveBalance
' Display Balance
' Run Calcs for Sick Leave here.
If IsNull(DSum("[DaysTaken]", "[qrySickLeaveRecs]", "[tblEmployees]![EmployeeID] = [tblLeaveRecord]![EmployeeID]")) Then
TotSLeaveRecorded = 0
Else
TotSLeaveRecorded = DSum("[DaysTaken]", "[qrySickLeaveRecs]", "[tblEmployees]![EmployeeID] = [tblLeaveRecord]![EmployeeID]")
End If
' Calculates the number of leave days taken from leave records in database based on qrySickLeaveRecs
' Used IsNull to check if there are no records found - set calc result to zero
Me.Taken02 = TotSLeaveRecorded 'visible option = no
' Display this on screen
Me.Bal02 = Me.SickLeaveDue - TotSLeaveRecorded
' Display Sick Leave Balance
thanks in advance ...
View Replies
ADVERTISEMENT
May 26, 2015
I'm currently trying to make the call answering screens a bit better in the call centre that i work in. i'm trying to make a caller i.d. for incoming calls. i have a reference library from the telephone software people in vba that lets me dial and hangup the phone, now i'm trying to place a text box on the form that will update to show the number of an incoming call which will enable me to search a table of contacts and display the details of the caller if they are available. i'm guessing that i need to create a loop that will run until there is an incoming call but i don't know where to place the code without it needing a mouse click or mouse over to trigger it. i just want it to run constantly.
View 5 Replies
View Related
Dec 7, 2005
Hi,
In a form a have a field wich contains for exemple 'ABCD', is it possible to place focus in this field after the last character (after the D in my exemple).
Thanks in advance.
VINCENT
View 2 Replies
View Related
Jan 27, 2007
i have a statement like this:
rs![tblRecurringDefects] = f("txtTotalRecurring" & i) / f("txtTotalJobs" & i) * 100
how can i have two decimal place?
View 1 Replies
View Related
Aug 11, 2007
Hey all
I'm looking to get Access 2007. Anyone know the cheapest place to get it? I'm in UK but if importing is cheaper I'd be interested.
Thanks for your help
View 7 Replies
View Related
Jun 14, 2006
Hey everyone,
I'm playing with my DB a bit and I need help in determing which way to go. When I print out labels for Envelopes or directly on envelopes, sometimes I have people living on the same address (a family), so I would like to save some on printing and actually sending several envelopes to the same address.
Now, I was thinking of doing this through the code in VBA but now I'm thinking if there is maybe more simple and faster way in building a qry.
All the data for the labels and envelops comes to a temp table from where I'm printing out reports...so what I'm not sure, is there a way to make a querry which would go through my temp table sorted by address, pick address1 then address2, if they are the same, check if lastname1 and lastname2 ise the same and then name1=name1 & Name2, delete record2 and go on...
tnx a lot
View 2 Replies
View Related
Mar 4, 2008
My sql code reads as follows:
Total ATR: Round([Total Resolved] / ([Total Resolved] + [Total Escalated]) * 100) & "%"
This will round to a whole.
When I try to set it to round to the tenth it fails.
I tried using
Total ATR: Round((([Total Resolved] / ([Total Resolved] + [Total Escalated]) * 100) & "%"),2)
Any ideas?
View 3 Replies
View Related
Jan 17, 2006
Is there an easy way of doing this? I have a database that I want to automatically place racers as they finish. I have four race divisions. All racers no matter the division start at the same time. I have all of this figured out, but what is getting me is the finish place (1st, 2nd, etc.) Is there a way on a continuos form to automatically place the racers? How this works is...Main form has racer info., on this form is a stop button, and after the button is clicked, it will show his/her finishing place in their division which is subform of the main form. Here is the reason I want this. Someone may have registered wrong and they are in the wrong division, and we have to change them to the correct division after they have finished and already been placed. I want to be able to move them to the right division, and then my subform requery and they placed in the correct position in the new division. Sorry this is so lenghty. Plain and simple can I make a subreport have an unbound field that shows each records place the recordset? Thanks for your help, and like I said sorry this is so long.
View 4 Replies
View Related
Sep 27, 2004
I am building a database from a detailed Excel file which has upwards of 22 decimal places. Access restricts the decimal usage to 15 characters. Even when selecting the 15 characters, Access rounds the entry. The only way it will work so far is as text, but it is a calculated field. Any suggestions?
View 3 Replies
View Related
Dec 6, 2004
Hey everyone - is there a way within Access to set the decimal places so that it holds a 0 after the decimal if you put it in that way, but also uses Auto for the # of decimal places? For example, I'm trying to create a DB in which one of the fields is to hold GPAs. It obviously looks silly to have it displayed as 4 if it's 4.0, but I would also prefer to not set the decimal places at 3 and have it displayed as 4.000. I can do this if I have to, but what would be most preferable would be to have it record the number exactly the way I put it in, whether it's 4.0 or 3.875 without cutting off anything (0's or multi-digit decimals) after the decimal. Is this possible, or do I have to customize the output in ASP?
Thanks!
View 2 Replies
View Related
Sep 3, 2012
I have made a powerpoint presentation from inside Access. I have a form that populates the fields based on user input. I would like to put a copy of this form into a powerpoint slide after the data has updated. Is there a way to do this?? I have tried numerous code variations and can't seem to get anything to work.
I am using Office 2003. My supervisors are comfortable with the display of the form the way it is. So I really need to use a picture of the form and not just the info contained in the form (otherwise i would just fill the slide with the data from the query)...
View 4 Replies
View Related
May 31, 2005
Hi, I want to create an access app that will allow a user to see the number of pages printed by various printers.
These are the data that I have:
Model Type (various are available)
Printer's name (unique to one printer)
IP addr (unique to printer)
Quantity printed (such as Single Legal, Double Legal, Single Letter,etc)
This is what I have (2 tabels with 1-many relationship):
Printers
PrinterID
Model
Name
IP
ModelTypes
ModelID
Model
Now, where do I place the quanties of paper printed? Do I just leave it in Printers?
Thanks.
View 9 Replies
View Related
Apr 13, 2007
Hi,
I have a query that is run off a form. When the query opens up there is a field you can enter data into. Once you close the query the data saves into the proper place in the table. That all works great.
I'm trying to make this as user friendly as possible. Instead of having someone go up to the "x" in the top right hand corner to close the query can I place a command button in the query that is very noticeable?
Any thoughts are most welcome
Thanks
Eddie.
View 2 Replies
View Related
Feb 10, 2005
Hello,
I have a subform that is based on a SQL statement that sums by Dollar Amount and groups by Account. I have it set up so the user can double-click on an account, which opens an unbound form. I then have the form execute a SQL INSERT INTO statement, which works beautifully.
The form opens as a pop-up, and I have it requery the subform when it closes. However, when the pop-up closes, I go back to the first record on the sub-form. I need it to "remember" the record I was on and take me back to that one. What is the standard procedure for doing this?
Thanks in advance!
Eric
View 2 Replies
View Related
May 12, 2005
From a form I want to be able to use a button to take a value from a designated field and search the internet for the given value
View 4 Replies
View Related
Oct 4, 2005
Hello, I ran into another programming road block.
I currently have a combo box that is bound to a table with 2 fields and has 4 different options/records in it, with an after update procedure, that has different calculations for each record. I want to add a Dlookup command that will display
the record that is chosen and it will need to be placed in the
after update procedure of the combo box also. Is this possible?
Code that is currently in the after update procedure of the combo box.
Dim prp As Property, ctl As Control
Set prp = Me!cboRidge.Properties("ListIndex")
Set ctl = Me.txtRidgetot
If prp = 0 Then
ctl = ([txtridge]*100/30)+0.4
ElseIf prp = 1 Then
ctl = ([txtridge]*100/45)+0.4
ElseIf prp = 2 Then
ctl = ([txtridge]*100/30)+0.4
Else
ctl = ([txtridge]*100/30)+0.4
End If
Set ctl = Nothing
Set prp = Nothing
Code I need to add:
Me.DLookcbotile.Requery
Thanks-- any help will be very appreciated.
View 1 Replies
View Related
Jan 18, 2006
On a from I am creating I want to make it user friendly. They enter an amount for a percentage. I have the format set to percentage. If you type in 99 you get 9900% instead of 99%. Is there an easy way to correct this?
Thanks
View 4 Replies
View Related
Jul 28, 2006
Hi I have a Contact form with all the details of the contacts, I would like to add a photo for each contact, how can I get to this?
Marco
View 1 Replies
View Related
Sep 21, 2006
No? Yes? If, so how?
View 2 Replies
View Related
Dec 3, 2004
Can anyone recommend a good place to upload a database so others can access it.
View 1 Replies
View Related
Oct 4, 2005
I currently have a combo box that is bound to a table with 2 fields and has 4 different options/records in it, with an after update procedure, that has different calculations for each record. I want to add a Dlookup command that will display
the record that is chosen in another text box and it will need to be placed in the
after update procedure of the combo box also. Is this possible?
Code that is currently in the after update procedure of the combo box.
Private Sub cbofelts_AfterUpdate()
Dim prp As Property, ctl As Control
Set prp = Me!cbofelts.Properties("ListIndex")
Set ctl = Me.txtfelts
If prp = 0 Then
ctl = ([TOTFLDSQ] / 4) + 0.4
ElseIf prp = 1 Then
ctl = ([TOTFLDSQ] / 2) + 0.4
ElseIf prp = 2 Then
ctl = [TOTFLDSQ] + 0.4
Else
ctl = ([TOTFLDSQ] / 3) + 0.4
End If
Set ctl = Nothing
Set prp = Nothing
End Sub
Code I need to add: (2nd after update procedure)
Me.Dlookfelts.Requery
Thanks-- any help will be very appreciated.
View 1 Replies
View Related
Sep 30, 2013
I have below vba code in a sub that opens word application and generates the data from a table based on criteria provided thru a form.
These lines are smoothly working..
But I need to place some headings in first line or second line of the document and then to start the table information to appear in the doc.
I tried to place my company name below way (see bold lines);
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim I As Integer
Set db = CurrentDb()
Set rs = db.OpenRecordset("SELECT * FROM T_CustomerMaster WHERE SALESMANCODE='" & Forms!F_ReportMaster!TxtRepCode & "' order by custcode;")
WordSetup
doc.Tables.Add Range:=doc.Range, numrows:=1, numcolumns:=5
'Trying to place main heading
'doc.Range(1, 0).Text = "fsdafds"
[Code] ....
But the table starting from column 1 and cell 1 till data ends up.
Finally I converted my trial lines to remark as it is not working at all.
View 8 Replies
View Related
Mar 19, 2012
Is there a way to place greater than and less than parameters within vba access? I have tried so many ways for hours today trying to meet my objective.
Objective1: When the user clicks vbno on a message box display.. I want the user to have a constraint in the text box between 0 and 100, and the value cannot be 0 nor 100, simply between.
Background: This same text box has different constraints, where when yes is clicked. The value is 100. The textbox also has a must be 0 constraint when nothing is typed.
Objective2: I would like, when the user clicks the next record button, to have an error message when the user's entry is not between 0 and 100 once vbno is clicked.
I was attempting to use the option of calling a subroutine, however, access would not give the user enough time to enter data before an error message is displayed.I even tried to see if I could call the vbno function during the click event for new record. I do not know how to do that.
View 3 Replies
View Related
Apr 14, 2008
Okay my access skills are low at best and I'm trying to build a database for work so hopefully this isn't to stupid of a question.
I'm trying to creat a query that will allow the user to type in a work type and have it generate the all records containing that work type. The way the data is in there to get it to generate just a specific work type without the input I have to use Like "*newacct*" for example. Is there any way to do this since there are more then one work types for some records?
Thank you
View 8 Replies
View Related
Mar 16, 2006
When I create an option group, the buttons or checkboxes appear to the left of the labels. Is there an easy way to make them come out on the right side of the labels? When I move them around manually it is hard to make the buttons align properly with the labels.
View 2 Replies
View Related
Aug 11, 2014
I am currently using access 2010 and I have been wrecking my brain to figure out how to display message in place of my charts when there is no data. Currently, whenever the chart has no data to display it just shows a white blank space. I would like to replace that with a message.
View 12 Replies
View Related