HELP

S

sirajut

i have three rows and three col A B C
1

2

3

I WANT C3 =B3-C2 BUT WHEN B3 IS GREATER THEN IWANT C 3 =AI -C2 CAN IT
POSSIBLE
 
M

Mustaq Sheikh

Assuming the table name is "THREE" and you have an ID field set to 1, 2 and 3 for the relevant rows, this should do it:

Sub UpdVals()
'I WANT C3 =B3-C2 BUT WHEN B3 IS GREATER THEN IWANT C 3 =AI -C2 CAN IT
'POSSIBLE
Dim db As Database
Dim rs As Recordset
Dim C3, B3, C2, A1

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT B FROM THREE WHERE ID=3")
If Not rs.EOF Then
B3 = Nz(rs!B)
Else
GoTo ExitProc
End If

Set rs = db.OpenRecordset("SELECT C FROM THREE WHERE ID=2")
If Not rs.EOF Then
C2 = Nz(rs!C)
Else
GoTo ExitProc
End If

Set rs = db.OpenRecordset("SELECT A FROM THREE WHERE ID=3")
If Not rs.EOF Then
A1 = rs!A & ""
Else
GoTo ExitProc
End If

If B3 <= C2 Then
db.Execute "UPDATE THREE SET C=" & B3 - C2 & " WHERE ID=3"
Else
db.Execute "UPDATE THREE SET C=" & A1 - C2 & " WHERE ID=3"
End If


ExitProc:

End Sub



sirajut wrote:

HELP
24-Nov-09

i have three rows and three col A B






I WANT C3 =B3-C2 BUT WHEN B3 IS GREATER THEN IWANT C 3 =AI -C2 CAN I
POSSIBLE

Previous Posts In This Thread:

EggHeadCafe - Software Developer Portal of Choice
Keep ViewState out of Page for Performance Enhancement Redux
http://www.eggheadcafe.com/tutorial...8-64dd33bfc2fe/keep-viewstate-out-of-pag.aspx
 
J

John W. Vinson

i have three rows and three col A B C
1

2

3

I WANT C3 =B3-C2 BUT WHEN B3 IS GREATER THEN IWANT C 3 =AI -C2 CAN IT
POSSIBLE

It sounds like you're using Excel rather than Access. Are you? If so please
repost the question in a newsgroup supporting Excel.

A clearer statement of the question would certaionly help. "When B3 is
greater" ... greater than what?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top