473,769 Members | 2,141 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Please help me read this code

When it comes to access, I'm pretty good using the built in features
and can come up with some pretty complex functions to get what I need.
But we have this database I'm doing for work that is trying to pull in
too many things. The database is a construction job estimating
program. First you setup a project, then you add items that will be
needed for the job and you create a cost estimate. You then send this
list out to construction companies who turn in their bids, which are
added in to the program. The last step is to create a bid tabulation
report, that is a cross tab of the original estimate along w/ the bids
from the various construction companies.

This was more complex than I could handle, so we hired someone to do
it. 4 attempts later and a few thousand dollars and this report still
does not function properly. Right now I'm attempting to learn VBA
and fix this damned thing myself.

But, I'm having trouble making sense fo this code he's put in, to
figure out why 1 out of 5 times the "Total" variable puts in a "$1"
instead of calculating the total by multiplying the unit * quantity.

Any help would be greatly appreciated.

Below is the code:

Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
' Place values in text boxes and hide unused text boxes.
Dim Contractor As String
Dim TempContractor
'Dim ItemCombo As Long
Dim ItemCombo As String
Dim i As Integer
Dim intX As Integer
Dim TempWMTotal As Single
' Verify that not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, place values from recordset into text
boxes
' in detail section.
If Me.FormatCount = 1 Then

For intX = 9 To intColumnCount
' Convert Null values to 0.
TempContractor = Me("Head" + Format$(intX))
' Replace underscores with periods (reversing what
cross tab query does with periods)
Contractor = ""
For i = 1 To Len(TempContrac tor)
If Mid(TempContrac tor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContrac tor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Field s("itemcombo" )
ItemCombo = rstReport.Field s("itemcombo" )
Me("Unit" + Format$(intX)) = xtabCnulls(rstR eport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenR ecordset("SELEC T * FROM
[qryBidtabulatio nStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Field s("TotalCharge" )
ColumnTotals(in tX) = ColumnTotals(in tX) +
rstTotals.Field s("TotalCharge" )
Me.WMTotal = rstTotals.Field s("WMTotalItemC harge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity")
Else
Me("Diff" + Format$(intX)) = ""
End If

rstTotals.Close
Next intX
WMTotalTotal = WMTotalTotal + TempWMTotal
' Hide unused text boxes in detail section.
For intX = intColumnCount + 1 To conTotalColumns
Me("Unit" + Format$(intX)). Visible = False
'Me("DLine" + Format$(intX)). Visible = False
Next intX

' Move to next record in recordset.
rstReport.MoveN ext
End If
End If

End Sub

Nov 12 '05 #1
2 2226
If you would like my help, contact me at re******@pcdata sheet.com.
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
www.pcdatasheet.com
"Jayjay" <jj****@notmail .com> wrote in message
news:3f******** *******@news.ci s.dfn.de...
When it comes to access, I'm pretty good using the built in features
and can come up with some pretty complex functions to get what I need.
But we have this database I'm doing for work that is trying to pull in
too many things. The database is a construction job estimating
program. First you setup a project, then you add items that will be
needed for the job and you create a cost estimate. You then send this
list out to construction companies who turn in their bids, which are
added in to the program. The last step is to create a bid tabulation
report, that is a cross tab of the original estimate along w/ the bids
from the various construction companies.

This was more complex than I could handle, so we hired someone to do
it. 4 attempts later and a few thousand dollars and this report still
does not function properly. Right now I'm attempting to learn VBA
and fix this damned thing myself.

But, I'm having trouble making sense fo this code he's put in, to
figure out why 1 out of 5 times the "Total" variable puts in a "$1"
instead of calculating the total by multiplying the unit * quantity.

Any help would be greatly appreciated.

Below is the code:

Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
' Place values in text boxes and hide unused text boxes.
Dim Contractor As String
Dim TempContractor
'Dim ItemCombo As Long
Dim ItemCombo As String
Dim i As Integer
Dim intX As Integer
Dim TempWMTotal As Single
' Verify that not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, place values from recordset into text
boxes
' in detail section.
If Me.FormatCount = 1 Then

For intX = 9 To intColumnCount
' Convert Null values to 0.
TempContractor = Me("Head" + Format$(intX))
' Replace underscores with periods (reversing what
cross tab query does with periods)
Contractor = ""
For i = 1 To Len(TempContrac tor)
If Mid(TempContrac tor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContrac tor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Field s("itemcombo" )
ItemCombo = rstReport.Field s("itemcombo" )
Me("Unit" + Format$(intX)) = xtabCnulls(rstR eport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenR ecordset("SELEC T * FROM
[qryBidtabulatio nStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Field s("TotalCharge" )
ColumnTotals(in tX) = ColumnTotals(in tX) +
rstTotals.Field s("TotalCharge" )
Me.WMTotal = rstTotals.Field s("WMTotalItemC harge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity")
Else
Me("Diff" + Format$(intX)) = ""
End If

rstTotals.Close
Next intX
WMTotalTotal = WMTotalTotal + TempWMTotal
' Hide unused text boxes in detail section.
For intX = intColumnCount + 1 To conTotalColumns
Me("Unit" + Format$(intX)). Visible = False
'Me("DLine" + Format$(intX)). Visible = False
Next intX

' Move to next record in recordset.
rstReport.MoveN ext
End If
End If

End Sub

Nov 12 '05 #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The news group readers (we) would need to know what you want the
report to do/show; what the RecordSource of the report looks like;
what is this procedure supposed to be doing - it looks like it is
calculating totals. This may be more easily done using the control's
Running Sum property instead of using a function that calculates
totals.

The procedure holds a reference to a Recordset variable (rstReport)
that is not defined in the procedure. We'd need to know what records
this recordset is working with, so we can better understand why it is
being used. My guess - it is the same recordset that is produced by
the Report's RecordSource.

What records are returned by the Recordset "rstTotals" ? It looks like
it is supposed to return one record that is probably a summary (hence,
the name rstTotals). This record's field's data are put into controls
on the report - probably a summary line. If a summary it may be
easier to put a Footer section that could hold the totals (summary)
controls.

Summary control's ControlSource:

=Sum([Column1]) or =Avg([Column1])
Regards,

MGFoster:::mgf
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP7Ax54echKq OuFEgEQLEFQCeN0 8bpFB2L7kmPQ8I7 jMp9a665FEAnjqY
OtYnSngUP5jvqgs 4B27JkFhW
=VKBh
-----END PGP SIGNATURE-----

Jayjay wrote:
When it comes to access, I'm pretty good using the built in features
and can come up with some pretty complex functions to get what I need.
But we have this database I'm doing for work that is trying to pull in
too many things. The database is a construction job estimating
program. First you setup a project, then you add items that will be
needed for the job and you create a cost estimate. You then send this
list out to construction companies who turn in their bids, which are
added in to the program. The last step is to create a bid tabulation
report, that is a cross tab of the original estimate along w/ the bids
from the various construction companies.

This was more complex than I could handle, so we hired someone to do
it. 4 attempts later and a few thousand dollars and this report still
does not function properly. Right now I'm attempting to learn VBA
and fix this damned thing myself.

But, I'm having trouble making sense fo this code he's put in, to
figure out why 1 out of 5 times the "Total" variable puts in a "$1"
instead of calculating the total by multiplying the unit * quantity.

Any help would be greatly appreciated.

Below is the code:

Private Sub Detail_Format(C ancel As Integer, FormatCount As Integer)
' Place values in text boxes and hide unused text boxes.
Dim Contractor As String
Dim TempContractor
'Dim ItemCombo As Long
Dim ItemCombo As String
Dim i As Integer
Dim intX As Integer
Dim TempWMTotal As Single
' Verify that not at end of recordset.
If Not rstReport.EOF Then
' If FormatCount is 1, place values from recordset into text
boxes
' in detail section.
If Me.FormatCount = 1 Then

For intX = 9 To intColumnCount
' Convert Null values to 0.
TempContractor = Me("Head" + Format$(intX))
' Replace underscores with periods (reversing what
cross tab query does with periods)
Contractor = ""
For i = 1 To Len(TempContrac tor)
If Mid(TempContrac tor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContrac tor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Field s("itemcombo" )
ItemCombo = rstReport.Field s("itemcombo" )
Me("Unit" + Format$(intX)) = xtabCnulls(rstR eport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenR ecordset("SELEC T * FROM
[qryBidtabulatio nStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Field s("TotalCharge" )
ColumnTotals(in tX) = ColumnTotals(in tX) +
rstTotals.Field s("TotalCharge" )
Me.WMTotal = rstTotals.Field s("WMTotalItemC harge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Field s("Quantity")
Else
Me("Diff" + Format$(intX)) = ""
End If

rstTotals.Close
Next intX
WMTotalTotal = WMTotalTotal + TempWMTotal
' Hide unused text boxes in detail section.
For intX = intColumnCount + 1 To conTotalColumns
Me("Unit" + Format$(intX)). Visible = False
'Me("DLine" + Format$(intX)). Visible = False
Next intX

' Move to next record in recordset.
rstReport.MoveN ext
End If
End If

End Sub


Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1356
by: abmd.tw | last post by:
dear all : please help me to slove the problem as below code , it can't run . i want to read a file and display. #include <iostream> #include <fstream> #include <cstdlib> #include <assert.h>
1
3443
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this. Before: ----------
1
1716
by: A Hirsi | last post by:
I have created a vb .net program as a service that is using a simple ftpclient to connect to a remote server and check the status of a file for subsequent downloading if there have been changes to it. I have been having many problems and need your help. 1. When I use a thread to start the service it only runs once and quits. I do not see any of my eventlog.writelog entries again. 2. I used a timer that fires off every 10 seconds (for...
1
9651
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
1
54532
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and we instruct our experts to ignore any such PMs completely Be sure to give the version of Access that you are working with and the Platform and OS if applicable.
4
4611
by: H-S | last post by:
Please help. This is a real puzzler! Originally posted on microsoft.public.dotnet.framework.windowsforms but no answer found! I have a read-only textBox which shows the results of a selection on another form. When the selection changes from the saved data, I wish to show it a different colour. As it is read-only the ForeColor property has no effect.
22
3276
by: Amali | last post by:
I'm newdie in c programming. this is my first project in programming. I have to write a program for a airline reservation. this is what i have done yet. but when it runs it shows the number of seats as 0 and the flight no. is also repeating. If any can tell why is this please help me. #include<stdio.h> #include<ctype.h> #include<conio.h>
4
4262
by: skunapareddy | last post by:
I am needing to read a blob from database and pass it to another java program. I researched internet and found a program that reads a file on the client pc and gives bytes, but when I modified the code to read a blob from DB I am not having any luck, I am running this java programs using JDEVELOPER. Can anyone please give me some help? The code is as follows: ... private static byte getBytesFromBlob(Blob blob) throws Exception { ...
1
25268
Markus
by: Markus | last post by:
Before you post please: Turn on PHP Debugging Messages - this will help yourself and our experts to solve your problem. Please provide the error details in your post. Read the Posting Guidelines. Some of the main posting guidelines we would like you to follow when posting (in brief): Pick a good thread title -
1
2774
by: DarkGiank | last post by:
Hi, im new to csharp and im trying to create a class that can change the application database without no rewriting all connection code... but cause some reason it is not working... it tells me that im not creating the object but im doing it,,, please help im a newbie to c# using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SQLite; using MySql.Data; using MySql.Data.MySqlClient; using...
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9981
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7396
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.