Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can someone help me with an if statement in a modual

Status
Not open for further replies.

R9772

Technical User
Aug 15, 2002
76
0
0
US
can someone help me create a function in Access that uses if statements to act on tables.

for instance (select *,if [my design] = [new product] then [new funding] / 12 into [new column] from products)

thanks
 
Looks like you are trying to mix SQL and VBA together in one line. Trying writing out what you want this code to do. That way we can help you more. Include table relations, how they are connected, and exactly what you want the above statement to do.

If I take a peek in your Windows, to fix a problem, does that make me a "Peeping Tom"? Hmmmmmmmmmm
 
R,

This is just a vague answer, because it is not clear
from your question what your table structure is and
what kind of form you have.

This assumes that you have controls on your form named
ProductName and NewFunding. They relate to two data
fields in YourTable.

You can put this code in the AfterUpdate event of
your form.

Code:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim sql As String

Set dbs = CurrentDb

'
' Check to see if product is new, or old
'
sql = "Select * " & _
      "From   YourTable " & _
      "Where  ProductName = '" & Me.NewProduct & "'"
Set rst = dbs.OpenRecordset(sql)
If rst.EOF and rst.BOF Then
   ' New Product
   rst.AddNew
   rst.ProductName = Me.ProductName
   rst.NewFunding = Me.NewFunding
   rst.Update
Else
   ' Existing product
   rst.Edit
   rst.NewFunding = rst.NewFunding
   rst.Update
End If

Wayne
 
i apologize for being unclear. i hope the following is a little better description than i provided earlier.

my first table has the following columns cn(customer name), prod(old products) and funding. my second has designs(new products), co(company), funding(new funds allotted) and cst(cost).

what i want to do is replace old products funding amount with new funding wherever they match on "designs" and "prod". if possible,i would like to create a new column that tracks where i make changes with the amount of those changes.


thanks again for you help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top