Below is the problem I'm trying to do....
Steel Fabricators purchases raw steel to fabricate beams and other
parts used in large buildings. It purchases its steel from many
overseas sources. Due to currency fluctuations in the countries in
which the steel is purchased, the price must frequently be changed
for each item from a particular country. Prices can be changed
upward or downward depending on the country of origin. Steel
Fabricators needs a program to update the prices and to view the
price list. When complete, the main form for the program should
look like Figure 8-21.
a) Run the executable file named Chapter.08\Exercise\Ex2.exe.
The form contains option buttons to select the country as well as
option buttons to charge the prices. In addition, a text box
enables the user to indicate the percentage amount of the price
change. When the user clicks the Update Prices command button, the
prices for a particular country increase or decrease by the
percentage amount specified. The Display Prices command button
displays the current price list, and the Exit command button ends
the program. Note that for this executable program to run, the
database file Steel.mdb must reside in the same folder as the
executable file. The price entered should be a decimal value
between 0 and 1. For brevity, the percentage has not been checked
for errors. End the program.
b) Start Visual Basic and create a new project, if necessary.
c) Set the form name to frmEx2 and the caption to Steel
Fabricators � Update Prices.
d) Save the from as frmEx2.frm and the project as Ex2.vbp in
the Chapter.08\Exercise folder. Set the drive designator as
necessary.
e) In the general declarations section of the form module,
create a variable named gdbCurrent that can store the reference to a
Database object.
f) Open the database named Chapter.08\Exercise\Steel.mdb when
the form loads. Set the drive designator as necessary. Store a
reference to the open database in the object variable named
gdbCurrent.
g) Create a command button to exit the program.
h) Create a Frame object and set the caption to Country.
i) Create a control array of three option buttons named
optCountry. Set the captions of these option buttons to Brazil,
Korea, and Japan.
j) Create a second Frame object with the caption Price
Direction.
k) Create a control array of two option buttons named
optDirection in the frame. Set the captions of these option buttons
to Increase and Decrease.
l) Create a Frame object with the caption Percent and a text
box inside the frame named txtPercent.
m) Create two command buttons: one to update prices and another
to display a form containing the price list. Set the names and
captions as necessary.
n) In the command button to update prices, write the statements
in the Click event procedure to determine which option button the
user has selected and to store the selected country name in a String
variable.
o) Write the statements to store the price change percentage in
a variable having the Single data type. If the new price represents
an increase, the number should be positive. If the new price
represents a decrease multiple the number by -1 to make it negative.
p) In a local String variable, store an UPDATE statement that
will update the field namded fldItemPRice in the table named
tblPriceList where the field named fldCountry is the same as the
selected country. The price stored in fldItemPrice should be
increased or decreased by the percentage amount specified by the
user.
q) Create a form that will display and locate the records from
the table named tblPriceList. You can create this form manually or
use the Data Form Wizard to accomplish this task. Save the form
using the name frmPrices.frm. Use the fields named fldItemNumber,
fldCountry, fldItemDescription, and fldItemPrice.
r) Program the second command button on the main form to
display the newly created form as a modal form.
s) Test the program by displaying the original price list,
then increasing and decreasing the prices by different percentages.
t) Save the forms and project again. Exit Visual Basic.
Below this is the code in which I have wrote....
Option Explicit
Public gdbCurrent As Database
Public mrstCurrent As Recordset
Private pstrCountry As String
Private psngPercent As Single
Private psngDirection As Single
Private Sub cmdDisplayPrices_Click()
frmPrices.Show vbModal
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdUpdatePrices_Click()
Dim pstrSQL As String
Dim pstrTest As String
psngPercent = Val(txtPercent.Text)
If optCountry(0) Then
pstrCountry = "Brazil"
Else
If optCountry(1) Then
pstrCountry = "Koreo"
Else
If optCountry(2) Then
pstrCountry = "Japan"
End If
End If
End If
If optDirection(0) Then
psngDirection = (psngPercent * 1) +
frmPrices.txtItemPrice.Text
Else
psngDirection = (psngPercent * -1) +
frmPrices.txtItemPrice.Text
End If
pstrSQL = "UPDATE tblPriceList" & _
" SET fldItemPrice =" & psngDirection & _
" WHERE fldCountry =" & "pstrCountry"
mrstCurrent.Edit
mrstCurrent.Update
End Sub
Private Sub Form_Load()
Set gdbCurrent = OpenDatabase("A:\Chapter.08\Exercise\Steel.mdb")
Set mrstCurrent = gdbCurrent.OpenRecordset("tblPriceList")
End Sub
Option Explicit
Public gdbCurrent As Database
Private mrstCurrent As Recordset
Private Sub cmdClose_Click()
Me.Hide
End Sub
Private Sub LoadCurrentRecord()
txtItemNumber.Text = mrstCurrent![fldItemNumber]
txtCountry.Text = mrstCurrent![fldCountry]
txtItemDescription.Text = mrstCurrent![fldItemDescription]
txtItemPrice.Text = mrstCurrent![fldItemPrice]
End Sub
Private Sub Form_Load()
Dim pstrFields As String
pstrFields = "fldItemNumber, fldCountry, fldItemDescription,
fldItemPrice"
Set gdbCurrent = OpenDatabase("A:\Chapter.08\Exercise\Steel.mdb")
Set mrstCurrent = gdbCurrent.OpenRecordset("tblPriceList")
Call LoadCurrentRecord
End Sub
I need this back before tomorrow....if you all can help that would
be great...thanks for your time....
'// =======================================================
Rules : http://ReliableAnswers.com/List/Rules.asp
Home : http://groups.yahoo.com/group/vbHelp/
=======================================================
Post : [email protected]
Join : [EMAIL PROTECTED]
Leave : [EMAIL PROTECTED]
'// =======================================================
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/vbhelp/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/