Date in VBA Problem ?

G

Guest

i have a problem ; how to solve that first let give you the table structure
that i have
i
1) [Sno] number
2) [item] Text
3) [Price] number
4) [Date] Date/time

so i want to have a coding on a button on FORM such as

Private Sub Command4_Click()
With Form_Form1.Recordset
..MoveFirst
While (Not .EOF)
If (Form_Form1.item = "apple") Then
Form_Form1.price = 100
End If
..MoveNext
Wend
End With

End Sub

so the above coding do work and give the desire result [Price] 100 for
[tem] Apple
but i want to how to change the item price for a specific date item to 200

or

how to change today's date item apple price to 200
thanks


hope u got i
 
R

ruralguy via AccessMonster.com

Why not use a query to effect the changes? Have you played with the query
builder?

Naveed said:
i have a problem ; how to solve that first let give you the table structure
that i have
i
1) [Sno] number
2) [item] Text
3) [Price] number
4) [Date] Date/time

so i want to have a coding on a button on FORM such as

Private Sub Command4_Click()
With Form_Form1.Recordset
.MoveFirst
While (Not .EOF)
If (Form_Form1.item = "apple") Then
Form_Form1.price = 100
End If
.MoveNext
Wend
End With

End Sub

so the above coding do work and give the desire result [Price] 100 for
[tem] Apple
but i want to how to change the item price for a specific date item to 200

or

how to change today's date item apple price to 200
thanks

hope u got i
 
G

Guest

i need to know first the VBA Coding


second option would be the querry so teach me the querry option to make the
changes how to do that ............

ruralguy via AccessMonster.com said:
Why not use a query to effect the changes? Have you played with the query
builder?

Naveed said:
i have a problem ; how to solve that first let give you the table structure
that i have
i
1) [Sno] number
2) [item] Text
3) [Price] number
4) [Date] Date/time

so i want to have a coding on a button on FORM such as

Private Sub Command4_Click()
With Form_Form1.Recordset
.MoveFirst
While (Not .EOF)
If (Form_Form1.item = "apple") Then
Form_Form1.price = 100
End If
.MoveNext
Wend
End With

End Sub

so the above coding do work and give the desire result [Price] 100 for
[tem] Apple
but i want to how to change the item price for a specific date item to 200

or

how to change today's date item apple price to 200
thanks

hope u got i
 
R

ruralguy via AccessMonster.com

Hi Naveed,
Start with a select query and see if you can pull the records you want by
putting criteria in certain fields. Once you get the results you want then
change the query to an Update query. The point is you need to *play* with a
select query until you get it right.

Are you taking a class? Is this some course work?

Naveed said:
i need to know first the VBA Coding

second option would be the querry so teach me the querry option to make the
changes how to do that ............
Why not use a query to effect the changes? Have you played with the query
builder?
[quoted text clipped - 32 lines]
 
G

Guest

thanks for the select querry to update

but do u know plz how to do that in VBA

i guess tha is simple but i don't know that how to do

thanks

ruralguy via AccessMonster.com said:
Hi Naveed,
Start with a select query and see if you can pull the records you want by
putting criteria in certain fields. Once you get the results you want then
change the query to an Update query. The point is you need to *play* with a
select query until you get it right.

Are you taking a class? Is this some course work?

Naveed said:
i need to know first the VBA Coding

second option would be the querry so teach me the querry option to make the
changes how to do that ............
Why not use a query to effect the changes? Have you played with the query
builder?
[quoted text clipped - 32 lines]
hope u got i
 
R

ruralguy via AccessMonster.com

If .item = "apple" AND .DateField = #07/08/2007# Then

Naveed said:
thanks for the select querry to update

but do u know plz how to do that in VBA

i guess tha is simple but i don't know that how to do

thanks
Hi Naveed,
Start with a select query and see if you can pull the records you want by
[quoted text clipped - 14 lines]
 
J

jahoobob via AccessMonster.com

Folks, One of the Access(SQL commandments is:
"THOU SHALT NOT USE A RESERVED WORD AS A FIELD NAME!"
I believe that Date is probably the most misused reserved word.
Change [Date] and see what happens. Even if this doesn't fix your problem
you've got a clean slate from which to work on the real problem.


Naveed said:
i have a problem ; how to solve that first let give you the table structure
that i have
i
1) [Sno] number
2) [item] Text
3) [Price] number
4) [Date] Date/time

so i want to have a coding on a button on FORM such as

Private Sub Command4_Click()
With Form_Form1.Recordset
.MoveFirst
While (Not .EOF)
If (Form_Form1.item = "apple") Then
Form_Form1.price = 100
End If
.MoveNext
Wend
End With

End Sub

so the above coding do work and give the desire result [Price] 100 for
[tem] Apple
but i want to how to change the item price for a specific date item to 200

or

how to change today's date item apple price to 200
thanks

hope u got i
 

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