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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

data in date format

Status
Not open for further replies.

autoIT

IS-IT--Management
May 10, 2006
68
US
I have a field of a table that has a date in the following format:

OCT-1-06

I wrote a data base in VB that will do something specific if this field is OCT-1-06, or will do something else if this field is OCT-2-06, so on and so forth. My dilema is actually checking what the information is in this field and my coding is basically the following. Please tell me what I need to do differently to not get the EOF BOF error:


Dim Period as Date/String(not sure which)
Period=tblO1.fields.item("Period")

If Period = "OCT-1-06" Then
more code will go here
else if Period = "OCT-2-06" Then
do this instead
end if

Not exact on the rules here. What is the correct coding for this.

Thanks
Adam
 




Hi,

Dates are not STRINGS.
Code:
If Period = #OCT-1-06#Then

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
skip,

never saw the pound sign coding before, would this work if i'm using access 2007 and vb. What do the pound signs represent, are they a wild card of sorts?

Adam
 
just tried it and i see what it does, but it turns the date into xx/xx/xxxx format and it needs to be OCT-1_06 format because OCT-1-06 represents first 10 days in October OCT-2-06 represents second 10 day.....
 



Converts a STRING to a DATE. Period must be defined as a DATE.
Code:
If Period = #OCT-1-06# Then
You might take a look at Select Case
Code:
Select Case Period
  Case #OCT-1-06#

  Case #OCT-2-06#

  Case Else 

End Select




Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
thought about the selec case and by your suggestion tried it but still getting the bof/eof error:

also have period variable set as date and column in table I'm sending the data to and the colum in which the info is coming from set to date as opposed to text. Just not sure what else to try.
Adam
 



If it's still not working, step into the procedure of put a break on that statement.

Ues the Watch Window to observe the VALUE in Period and the VALUE in #OCT-1-06#. Are they EQUAL???

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
im aware of how to step through but where is the wtach window.
 
what i meant was i know where it is but im not familar with how it works
 



View/Watch Window

You can select a varible/constant and open the WW or enter the name directly into the WW.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top