If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
A Complex Date Command?
What do you mean the same thing? Have you tried it for items where the
MerchantDOB is after today? D. "Curtis Stevens" wrote: I pasted this and same thing? No worries... Use this one instead: me.MerchantDOB = iif(format(me.MerchantDOB, "yyyy/mm") = format(date(), "yyyy/mm"), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), cdate(year(date) & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB))) Damian. "Curtis Stevens" wrote: I thought it was giving me an error. I tried this, seems to work for any date range that needs to go to 2007, but any thing from tomorrows date until the end of the yr is changing to 2007 and not 06. Curtis it's IIF not IF... the double I at the front wasn't a typo... D. "Curtis Stevens" wrote: Hi Damian, I tried this, but it is looking for more code, if statement not done? Can't figure this out, little beyond my head. Private Sub CmdDOBCopy_Click() me.MerchantDOB = if(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) End Sub You will lose data if you overwrite the DOB with a new date. I would consider doing it another way. Be that as it may, using code similar to this will achieve what you are after: me.MerchantDOB = iif(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) Damian. "Curtis Stevens" wrote: a text box named - MerchantDOB a command button named - CmdDOBAdj MerchantDOB may have someone's dob, like 06/02/1981. I can't use that format to be able to know when their bday is up, so I must convert it to 06/02/2007. Here's the tricky part. When I click the cmd button, I want it to change the dob in the text box according to what it is & what the current date is (today's date). For example, today's date is 11/1/06. If their DOB is 1/1/XX to 11/1/XX then I want it to change it to XX/XX/2007. But if it is 11/2/XX to 12/31/XX, then change it to XX/XX/2006. And this range would change accordinly with the current day's date. The only part that changes is the yr, from their DOB yr to 2006 or 2007. I then up it by one yr with another cmd button on the day of their bday so it comes around again next yr and so on. Is this too complicated? Thanks Curtis |
#12
|
|||
|
|||
A Complex Date Command?
Yes, I tried 11/2/2000 or 12/12/2000, etc. All changed to 2007.
What do you mean the same thing? Have you tried it for items where the MerchantDOB is after today? D. "Curtis Stevens" wrote: I pasted this and same thing? No worries... Use this one instead: me.MerchantDOB = iif(format(me.MerchantDOB, "yyyy/mm") = format(date(), "yyyy/mm"), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), cdate(year(date) & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB))) Damian. "Curtis Stevens" wrote: I thought it was giving me an error. I tried this, seems to work for any date range that needs to go to 2007, but any thing from tomorrows date until the end of the yr is changing to 2007 and not 06. Curtis it's IIF not IF... the double I at the front wasn't a typo... D. "Curtis Stevens" wrote: Hi Damian, I tried this, but it is looking for more code, if statement not done? Can't figure this out, little beyond my head. Private Sub CmdDOBCopy_Click() me.MerchantDOB = if(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) End Sub You will lose data if you overwrite the DOB with a new date. I would consider doing it another way. Be that as it may, using code similar to this will achieve what you are after: me.MerchantDOB = iif(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) Damian. "Curtis Stevens" wrote: a text box named - MerchantDOB a command button named - CmdDOBAdj MerchantDOB may have someone's dob, like 06/02/1981. I can't use that format to be able to know when their bday is up, so I must convert it to 06/02/2007. Here's the tricky part. When I click the cmd button, I want it to change the dob in the text box according to what it is & what the current date is (today's date). For example, today's date is 11/1/06. If their DOB is 1/1/XX to 11/1/XX then I want it to change it to XX/XX/2007. But if it is 11/2/XX to 12/31/XX, then change it to XX/XX/2006. And this range would change accordinly with the current day's date. The only part that changes is the yr, from their DOB yr to 2006 or 2007. I then up it by one yr with another cmd button on the day of their bday so it comes around again next yr and so on. Is this too complicated? Thanks Curtis |
#13
|
|||
|
|||
A Complex Date Command?
Ok - apologies for butting in. I generally find that by asking "stupid"
questions I end up being less stupid, and sometimes "Is it plugged in?" results in a long silence .... "Curtis Stevens" wrote in message ... I need the data like that as I do a lot with it. I have it setup so I go through my forms, see which birthday cards that need to be mailed, which go out 7 days before the day of or send out emails on the day of. I also use the data to know who gets the cards - to stuff the envelopes & print out labels for the month before, to get it all prepared, etc. That's why I need the data this way, do a lot of stuff with it! Curtis I reckon that's what he should be doing, but that's not what he specifically asked... |
#14
|
|||
|
|||
A Complex Date Command?
I have not been following this discussion all that closely, but one
possibility so that you don't need to change the DOB is to add a calculated field to a query: DateCalc: DateSerial(Year(Date()),Month([MerchantDOB]),Day([MerchantDOB])) Then use DateCalc in expressions or code: If DateCalc = Date Then MsgBox "Birthday Today" End If or If DateCalc + 7 = Date Then MsgBox "Birthday in exactly one week" End If You can look for date ranges in a parameter query or otherwise treat it as a date field for most purposes. Saves you having to change a value that shouldn't be changed, and simplifies things quite a bit. "Curtis Stevens" wrote in message ... Yes, I tried 11/2/2000 or 12/12/2000, etc. All changed to 2007. What do you mean the same thing? Have you tried it for items where the MerchantDOB is after today? D. "Curtis Stevens" wrote: I pasted this and same thing? No worries... Use this one instead: me.MerchantDOB = iif(format(me.MerchantDOB, "yyyy/mm") = format(date(), "yyyy/mm"), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), cdate(year(date) & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB))) Damian. "Curtis Stevens" wrote: I thought it was giving me an error. I tried this, seems to work for any date range that needs to go to 2007, but any thing from tomorrows date until the end of the yr is changing to 2007 and not 06. Curtis it's IIF not IF... the double I at the front wasn't a typo... D. "Curtis Stevens" wrote: Hi Damian, I tried this, but it is looking for more code, if statement not done? Can't figure this out, little beyond my head. Private Sub CmdDOBCopy_Click() me.MerchantDOB = if(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) End Sub You will lose data if you overwrite the DOB with a new date. I would consider doing it another way. Be that as it may, using code similar to this will achieve what you are after: me.MerchantDOB = iif(me.MerchantDOB = date(), cdate(year(date) + 1 & "/" & month(me.MerchantDOB) & "/" & day(me.MerchantDOB)), me.MerchantDOB) Damian. "Curtis Stevens" wrote: a text box named - MerchantDOB a command button named - CmdDOBAdj MerchantDOB may have someone's dob, like 06/02/1981. I can't use that format to be able to know when their bday is up, so I must convert it to 06/02/2007. Here's the tricky part. When I click the cmd button, I want it to change the dob in the text box according to what it is & what the current date is (today's date). For example, today's date is 11/1/06. If their DOB is 1/1/XX to 11/1/XX then I want it to change it to XX/XX/2007. But if it is 11/2/XX to 12/31/XX, then change it to XX/XX/2006. And this range would change accordinly with the current day's date. The only part that changes is the yr, from their DOB yr to 2006 or 2007. I then up it by one yr with another cmd button on the day of their bday so it comes around again next yr and so on. Is this too complicated? Thanks Curtis |
#15
|
|||
|
|||
A Complex Date Command?
Am I missing something? I tried to figure it out on my own, no luck.
What do you mean the same thing? Have you tried it for items where the MerchantDOB is after today? |
#16
|
|||
|
|||
A Complex Date Command?
I'm amazed I figured it out, but I found out what the problem was, here is
the code that works!!!! Thanks Damian! Me.MerchantDOB = IIf(Format(Me.MerchantDOB, "mm/dd") = Format(Date, "mm/dd"), CDate(Year(Date) + 1 & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB)), CDate(Year(Date) & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB))) |
#17
|
|||
|
|||
A Complex Date Command?
If the merchant has a birthday late in the year and you run the code in the
new year you will get the exact opposite result from what you expect. Also, it seems rather roundabout to use a type conversion function (CDate) when you already have date fields and functions. Since you aren't formatting the CDate result you will be using your system settings for the display, in which case DateSerial would be more direct: DateSerial(Year(Date()),Month(Me.MerchantDOB),Day( Me.MerchantDOB)) You could wrap a format around that, if you wish. "Curtis Stevens" wrote in message ... I'm amazed I figured it out, but I found out what the problem was, here is the code that works!!!! Thanks Damian! Me.MerchantDOB = IIf(Format(Me.MerchantDOB, "mm/dd") = Format(Date, "mm/dd"), CDate(Year(Date) + 1 & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB)), CDate(Year(Date) & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB))) |
#18
|
|||
|
|||
A Complex Date Command?
Sorry, I don't follow you, I tested this out, moved my clock to Jan & still
works fine. I'm simply using this code to convert the YR in their DOB to the yr it needs to be. A new record is added & it has their actual DOB yr and I need that changed to this or next yr according to when it falls per today's date. That's all I'm using it for. Curtis If the merchant has a birthday late in the year and you run the code in the new year you will get the exact opposite result from what you expect. Also, it seems rather roundabout to use a type conversion function (CDate) when you already have date fields and functions. Since you aren't formatting the CDate result you will be using your system settings for the display, in which case DateSerial would be more direct: DateSerial(Year(Date()),Month(Me.MerchantDOB),Day( Me.MerchantDOB)) You could wrap a format around that, if you wish. "Curtis Stevens" wrote in message ... I'm amazed I figured it out, but I found out what the problem was, here is the code that works!!!! Thanks Damian! Me.MerchantDOB = IIf(Format(Me.MerchantDOB, "mm/dd") = Format(Date, "mm/dd"), CDate(Year(Date) + 1 & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB)), CDate(Year(Date) & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB))) |
#19
|
|||
|
|||
A Complex Date Command?
I'm saying that if a merchant's birthday is on December 29 and you run the
code on December 31, 12/29 12/31. However, if you run the code on January 2, 12/29 1/2. That's how Access will evaluate a date consisting of only month and day. My point in the posts I have made is that it seems to me you are using a complex and somewhat unreliable method to solve the problem. My point about CDate is that the function is used if a date is stored in a text field, and you need to evaluate the value (to see if it is in the future, or whatever). Assuming that your MerchantDOB field is a date field, both that field and the Date function are dates, so there is no need to use CDate to convert them to date values. "Curtis Stevens" wrote in message ... Sorry, I don't follow you, I tested this out, moved my clock to Jan & still works fine. I'm simply using this code to convert the YR in their DOB to the yr it needs to be. A new record is added & it has their actual DOB yr and I need that changed to this or next yr according to when it falls per today's date. That's all I'm using it for. Curtis If the merchant has a birthday late in the year and you run the code in the new year you will get the exact opposite result from what you expect. Also, it seems rather roundabout to use a type conversion function (CDate) when you already have date fields and functions. Since you aren't formatting the CDate result you will be using your system settings for the display, in which case DateSerial would be more direct: DateSerial(Year(Date()),Month(Me.MerchantDOB),Day( Me.MerchantDOB)) You could wrap a format around that, if you wish. "Curtis Stevens" wrote in message ... I'm amazed I figured it out, but I found out what the problem was, here is the code that works!!!! Thanks Damian! Me.MerchantDOB = IIf(Format(Me.MerchantDOB, "mm/dd") = Format(Date, "mm/dd"), CDate(Year(Date) + 1 & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB)), CDate(Year(Date) & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB))) |
#20
|
|||
|
|||
A Complex Date Command?
I just changed my system clock to 1/2/06 and tried 12/29/2000 and did it, it
changed to 12/29/2006, which is what I wanted. ??? I'm saying that if a merchant's birthday is on December 29 and you run the code on December 31, 12/29 12/31. However, if you run the code on January 2, 12/29 1/2. That's how Access will evaluate a date consisting of only month and day. My point in the posts I have made is that it seems to me you are using a complex and somewhat unreliable method to solve the problem. My point about CDate is that the function is used if a date is stored in a text field, and you need to evaluate the value (to see if it is in the future, or whatever). Assuming that your MerchantDOB field is a date field, both that field and the Date function are dates, so there is no need to use CDate to convert them to date values. "Curtis Stevens" wrote in message ... Sorry, I don't follow you, I tested this out, moved my clock to Jan & still works fine. I'm simply using this code to convert the YR in their DOB to the yr it needs to be. A new record is added & it has their actual DOB yr and I need that changed to this or next yr according to when it falls per today's date. That's all I'm using it for. Curtis If the merchant has a birthday late in the year and you run the code in the new year you will get the exact opposite result from what you expect. Also, it seems rather roundabout to use a type conversion function (CDate) when you already have date fields and functions. Since you aren't formatting the CDate result you will be using your system settings for the display, in which case DateSerial would be more direct: DateSerial(Year(Date()),Month(Me.MerchantDOB),Day( Me.MerchantDOB)) You could wrap a format around that, if you wish. "Curtis Stevens" wrote in message ... I'm amazed I figured it out, but I found out what the problem was, here is the code that works!!!! Thanks Damian! Me.MerchantDOB = IIf(Format(Me.MerchantDOB, "mm/dd") = Format(Date, "mm/dd"), CDate(Year(Date) + 1 & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB)), CDate(Year(Date) & "/" & Month(Me.MerchantDOB) & "/" & Day(Me.MerchantDOB))) |
Thread Tools | |
Display Modes | |
|
|