473,396 Members | 2,011 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,396 software developers and data experts.

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(Cancel 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(TempContractor)
If Mid(TempContractor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContractor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Fields("itemcombo")
ItemCombo = rstReport.Fields("itemcombo")
Me("Unit" + Format$(intX)) = xtabCnulls(rstReport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenRecordset("SELECT * FROM
[qryBidtabulationStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Fields("TotalCharge")
ColumnTotals(intX) = ColumnTotals(intX) +
rstTotals.Fields("TotalCharge")
Me.WMTotal = rstTotals.Fields("WMTotalItemCharge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Fields("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Fields("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.MoveNext
End If
End If

End Sub

Nov 12 '05 #1
2 2192
If you would like my help, contact me at re******@pcdatasheet.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.cis.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(Cancel 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(TempContractor)
If Mid(TempContractor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContractor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Fields("itemcombo")
ItemCombo = rstReport.Fields("itemcombo")
Me("Unit" + Format$(intX)) = xtabCnulls(rstReport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenRecordset("SELECT * FROM
[qryBidtabulationStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Fields("TotalCharge")
ColumnTotals(intX) = ColumnTotals(intX) +
rstTotals.Fields("TotalCharge")
Me.WMTotal = rstTotals.Fields("WMTotalItemCharge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Fields("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Fields("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.MoveNext
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/AwUBP7Ax54echKqOuFEgEQLEFQCeN08bpFB2L7kmPQ8I7jMp9a 665FEAnjqY
OtYnSngUP5jvqgs4B27JkFhW
=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(Cancel 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(TempContractor)
If Mid(TempContractor, i, 1) = "_" Then
Contractor = Contractor & "."
Else
Contractor = Contractor & Mid(TempContractor,
i, 1)
End If
Next i

'ItemCombo = rstReport.Fields("itemcombo")
ItemCombo = rstReport.Fields("itemcombo")
Me("Unit" + Format$(intX)) = xtabCnulls(rstReport(intX
- 1))
' filter recordset to display current Contractor's
record for current Combo Item
Set rstTotals = dbsReport.OpenRecordset("SELECT * FROM
[qryBidtabulationStep2] WHERE Contractor = '" & Contractor & "' AND
[itemcombo] = '" & CStr(ItemCombo) & "'")
Me("Total" + Format$(intX)) =
rstTotals.Fields("TotalCharge")
ColumnTotals(intX) = ColumnTotals(intX) +
rstTotals.Fields("TotalCharge")
Me.WMTotal = rstTotals.Fields("WMTotalItemCharge")
TempWMTotal = Me.WMTotal

If Me("Total" + Format$(intX)) <> Me("Unit" +
Format$(intX)) * rstTotals.Fields("Quantity") Then
Me("Diff" + Format$(intX)) = Me("Unit" +
Format$(intX)) * rstTotals.Fields("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.MoveNext
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
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
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....
1
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...
1
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...
1
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...
4
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...
22
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...
4
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...
1
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...
1
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...
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
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...
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.