Display billing month based on start date and end date

i have 3 textbox in a form with date type as date.
1- StartDate (bound to table)
2- EndDate (bound to table)
3- BillingMonth (unbound)

i want to display billing month based on start and end date according to
criteria that

 if startdate is 1/1/09 (format dd/mm/yy) and enddate is 28/1/09 (format
dd/mm/yy) , billingmonth should display [Jan-2009]

if startdate is 25/11/08 (format dd/mm/yy) and enddate is 28/1/09 (format
dd/mm/yy) , billingmonth should display [Dec-2008 to Jan-2009]

i have not much vb knowledge but tried the following code as control source
of billingmonth and as usual it didnt worked.


=IIf(Not IsNull([StartDate] & [EndDate]) & Datepart("m",[StartDate]) =
Datepart("m",[Enddate] & Datepart("y",[StartDate])= Datepart("y",[Enddate]) -
Format(Datepart("m",[StartDate]),"mmm") & '-' & Format(Datepart("y",
[StartDate]),"yyyy") - Format(Datepart("m",[StartDate]),"mmm") & '-' & Format
(Datepart("y",[StartDate]),"yyyy") & 'to ' & Format(Datepart("m",[EndDate]),
"mmm") & '-' & Format(Datepart("y",[EndDate]),"yyyy") 

any better solution.
Thanks in advance.

0
usm01
11/26/2009 12:29:22 PM
access.forms 6864 articles. 2 followers. Follow

5 Replies
1105 Views

Similar Articles

[PageSpeed] 38

Try:

=IIf(Format([StartDate], "yyyymm") = Format([EndDate], "yyyymm"), "[" & 
Format([StartDate], "mmm-yyyy") & "]", "[" & Format([StartDate], "mmm-yyyy") 
& " to " & Format([EndDate], "mmm-yyyy") & "]")


-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"usm01" <u56492@uwe> wrote in message news:9fb0e4adc2d56@uwe...
>i have 3 textbox in a form with date type as date.
> 1- StartDate (bound to table)
> 2- EndDate (bound to table)
> 3- BillingMonth (unbound)
>
> i want to display billing month based on start and end date according to
> criteria that
>
> if startdate is 1/1/09 (format dd/mm/yy) and enddate is 28/1/09 (format
> dd/mm/yy) , billingmonth should display [Jan-2009]
>
> if startdate is 25/11/08 (format dd/mm/yy) and enddate is 28/1/09 (format
> dd/mm/yy) , billingmonth should display [Dec-2008 to Jan-2009]
>
> i have not much vb knowledge but tried the following code as control 
> source
> of billingmonth and as usual it didnt worked.
>
>
> =IIf(Not IsNull([StartDate] & [EndDate]) & Datepart("m",[StartDate]) =
> Datepart("m",[Enddate] & Datepart("y",[StartDate])= 
> Datepart("y",[Enddate]) -
> Format(Datepart("m",[StartDate]),"mmm") & '-' & Format(Datepart("y",
> [StartDate]),"yyyy") - Format(Datepart("m",[StartDate]),"mmm") & '-' & 
> Format
> (Datepart("y",[StartDate]),"yyyy") & 'to ' & 
> Format(Datepart("m",[EndDate]),
> "mmm") & '-' & Format(Datepart("y",[EndDate]),"yyyy")
>
> any better solution.
> Thanks in advance.
> 


0
Douglas
11/26/2009 12:50:17 PM
Douglas J. Steele wrote:
>Try:
>
>=IIf(Format([StartDate], "yyyymm") = Format([EndDate], "yyyymm"), "[" & 
>Format([StartDate], "mmm-yyyy") & "]", "[" & Format([StartDate], "mmm-yyyy") 
>& " to " & Format([EndDate], "mmm-yyyy") & "]")
>
>>i have 3 textbox in a form with date type as date.
>> 1- StartDate (bound to table)
>[quoted text clipped - 26 lines]
>> any better solution.
>> Thanks in advance.


Thanks. It Worked. 
But it ignores Null Field (i.e if Enddate is Null).

-- 
Message posted via http://www.accessmonster.com

0
usm01
11/27/2009 9:42:35 AM
You never mentioned that as a possibility in your original post...

What do you want if EndDate is Null: to use the current month?

=IIf(Format([StartDate], "yyyymm") = Format(Nz([EndDate], Date), "yyyymm"), 
"[" & Format([StartDate], "mmm-yyyy") & "]", "[" & Format([StartDate], 
"mmm-yyyy") & " to " & Format(Nz([EndDate], Date), "mmm-yyyy") & "]")

-- 
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"usm01 via AccessMonster.com" <u56492@uwe> wrote in message 
news:9fbc02509ae0c@uwe...
> Douglas J. Steele wrote:
>>Try:
>>
>>=IIf(Format([StartDate], "yyyymm") = Format([EndDate], "yyyymm"), "[" &
>>Format([StartDate], "mmm-yyyy") & "]", "[" & Format([StartDate], 
>>"mmm-yyyy")
>>& " to " & Format([EndDate], "mmm-yyyy") & "]")
>>
>>>i have 3 textbox in a form with date type as date.
>>> 1- StartDate (bound to table)
>>[quoted text clipped - 26 lines]
>>> any better solution.
>>> Thanks in advance.
>
>
> Thanks. It Worked.
> But it ignores Null Field (i.e if Enddate is Null).
>
> -- 
> Message posted via http://www.accessmonster.com
> 


0
Douglas
11/27/2009 11:56:59 AM
Douglas J. Steele wrote:
>You never mentioned that as a possibility in your original post...
>
>What do you want if EndDate is Null: to use the current month?
>
>=IIf(Format([StartDate], "yyyymm") = Format(Nz([EndDate], Date), "yyyymm"), 
>"[" & Format([StartDate], "mmm-yyyy") & "]", "[" & Format([StartDate], 
>"mmm-yyyy") & " to " & Format(Nz([EndDate], Date), "mmm-yyyy") & "]")
>
>>>Try:
>>>
>[quoted text clipped - 11 lines]
>> Thanks. It Worked.
>> But it ignores Null Field (i.e if Enddate is Null).

yes

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200911/1

0
usm01
11/27/2009 3:36:29 PM
usm01 wrote:
>>You never mentioned that as a possibility in your original post...
>>
>[quoted text clipped - 9 lines]
>>> Thanks. It Worked.
>>> But it ignores Null Field (i.e if Enddate is Null).
>
>yes


i found another solution

=IIF (ISNULL(STARTDATE),NULL ,IIF ( ISNULL(ENDDATE),NULL ,IIF(FORMAT
(STARTDATE,"YYYYMM") = FORMAT(ENDDATE,"YYYYMM"),FORMAT(STARTDATE, "MMM-YY"),
FORMAT(STARTDATE, "MMM-YY to ") & FORMAT(ENDDATE,"MMM-YY"))))

-- 
Message posted via http://www.accessmonster.com

0
usm01
11/27/2009 3:38:29 PM
Reply:

Similar Artilces:

Return a cell refernce based on a value
I have a value in worksheet A which is "x". In worksheet B column A have a list of values i.e. a,b,c,d...x,y,z and in column B I hav values relating to those in coumn A i.e. column A row 1 value is "a column B row 1 value is "apple", column A row 2 value is "b" and colum B row 2 value is "balloon", how do I get teh first worksheet to rea the value in one cell, find it in column A of the other worksheet an give back the value on teh same row in column B? Thank -- Message posted from http://www.ExcelForum.com Hi use the VLOOKUP function =VLOOKU...

what is the better way to start vc++
Hi I am basically a VB and C Programmer. I am planning to learn VC++. Can anybody suggest me the better way to start with Thanking you al Chinna Before getting into VC++, you should get familiar with C++. http://www.cplusplus.com/doc/tutorial/ For VC++, this is good... http://pomelo.ivia.es/mecanizacion/www/vcpp/ Cheers Jagadeesh "chinna" <anonymous@discussions.microsoft.com> wrote in message news:7E47E2D6-E467-4FC5-93C6-A14A61A0B6D7@microsoft.com... > Hi, > > I am basically a VB and C Programmer. I am planning to learn VC++. Can anybody suggest me the better wa...

How to handle blank date and time?
I use MFC Visual C++ 4.2 I am developing a database application using MS Access 2000. The problem I am dealing with is how to handle if the user does not enter the date. There is a condition where they can do that for Finish Process Date / Finish Process Time. I make the Date and Time as separate fields, both in the database and the application. On my application I use the COleDateTime data type. I have to save the blank Date and the blank Time, and I also have to acquire them back in order to display the data using the CListCtrl. What I am confusing is how to make the query? Is it...

Dual Displays
I want to connect my Sharp Aquos flat screen TV to my computer, and see my desktop on both the TV and computer monitor. Windows Vista Home Premium. HP Pavilion a1610n computer. Galaxy GeForce 8400 GS graphics card, outputs: 1-VGA, 1-DVI, and 1-SVGA. There is no HDMI port on the card. I connected a VGA cable between the motherboard "on-board" VGA port and the TV, figuring that I could use that output to work with the TV. The computer monitor is plugged into the GeForce graphics card. Tried the Desktop "Display Setting". It says, the number 2 monitor is "N...

Display a message box "this entry is a duplicate"
How can I display a message box on a form if the shipment number is a duplicate? I need a message box to pop up when user attempts to tab out of the field. Thank you. Something like: Private Sub txtShipNum_BeforeUpdate(Cancel As Integer) If DCount("*", "MyTable", "ShipNum = '" & Me.txtShipNum & "'") > 0 Then Msgbox Me.txtShipNum & " already exists." Cancel = True End If End Sub This assumes that your text box is named txtShipNum, that the name of the field in table MyTable is ShipNum...

Folder could not be displayed
I am running Windows XP and Outlook Express 6 just fine then one day my husband does something to my computer and his email account won't work. My email is working just fine but in his he cannot open his inbox. It says folder could not be displayed, and when you send and receive it gives you this error message: "An unknown error has occured. Account: 'incoming.verizon.net'. Server:'incoming.verizon.net'.Protocol:POP3, port: 110, Secure(SSL): No, error number: 0x800C013B" If anyone could help me with this I would greatly appreciate it. Thank you T...

Dynamic Range Based on Cell Result not Empty Cell
I use dynamic ranges in excel. I use them to name ranges that vary i size due to varyin data. For example, I may dump data in F2 which ma span 3 rows or 100 rows. I use the following formula to name th range: =OFFSET($F$2,0,0,COUNTA($F2:$F65536),1) However, I now want to define the range based on the cell result. Tha is assume that I have a constant formula from F2 to F102. However th cells in the column either have a number in them or a "" in them. Th formula above will automatically size the range to F2:F102 becuas there is a formula in every row. How can i write a formua...

how to display values in 3 cells into one cell
Anyone can help me how do I display the 3 separate different values in 3 cells into just one single cell ? thanks so much in advance. Either there was a typo or there's an echo in here. That line should have been: = A1 & " " & B1 & " " & C1 "Bradley Dawson" <bradleydawson@earthlink.net> wrote in message news:l464b.2224$Lk5.2093@newsread3.news.pas.earthlink.net... > In the target cell, type: > > = A1 & B1 & C1 > > where A1, B1, C1 are the cell addresses that you want to concatenate. > > If these have number...

MSN Bill Pay and MS Money 2004
I have multiple bank accounts setup in Money from different banks. I have them setup to auto download the transactions. I want to pay my bills for all of my accounts using MSN Bill Pay Service so I dont have to pay additional fees from each bank. However when I configure an account to pay using MSN Bill Pay it prevents the download of the statment from the bank. - How can I setup money so that I can pay all of my bills using MSN Bill Pay and still have my transactions downloaded directly from the bank. ...

field based on field
I feel like I've asked this before. How do I make a field based on another field in the same query? exp1=a+b exp2=val(expr1) How do I write expr2? Kou On Thu, 13 Dec 2007 09:01:02 -0800, Kou Vang wrote: > I feel like I've asked this before. How do I make a field based on another > field in the same query? > > exp1=a+b > > exp2=val(expr1) > > How do I write expr2? > > Kou Your above question can have more than one result depending upon field datatype and what you mean by using the "+". Did you want to concatenate or add? Since your...

find and count days in blocks of consecutive dates
I need to find a way using Excel to find blocks of consecutive dates in a list and then count how many days are in each block. Any help is appreciated. Hi if i'm understanding you correctly, you can use the COUNTIF function =COUNTIF(range,">="&datevalue("lowest_date"))-COUNTIF(range,">"&datevalue("highest_date")) e.g. =COUNTIF(A1:A23,">="&DATEVALUE("2/10/04"))-COUNTIF(A1:A23,">"&DATEVALUE("4/10/04")) counts all the days between 2/10/04 and the 4/10/04 inclusive PS you might nee...

How to select & display distinct values
Hello, I need help with a form please. My form has two controls, the first being a combo box. This box should select the company name from a lookup table. The lookup table has only two companies in it, however, they each are repeated several time. Company 1 has about 10 rows, company 2 has 3 rows. I used the query builder and came up with the statement: "SELECT DISTINCT Lktbl_Role_Master.CompanyName FROM Lktbl_Role_Master;" When I run the statement directly from query view, it executes perfectly and returns exactly two rows (one for each company, in a datasheet view) ho...

using the down end
I am trying to use the down_end statement in a macro and it always lands on the same spot. I want to copy something from sheet_1 to the first open cell in sheet_2. This position will change each time I copy data to it. Can someone help me. Thank you. Ed Davis dlr=sheets("sheet2").cells(rows.count,"a").end(xlup).row+1 sheets("sheet1").range("something").copy sheets("sheet2").cells(dlr,1) -- Don Guillett Microsoft MVP Excel SalesAid Software dguillett1@austin.rr.com "Ed Davis" <ed.davis1@verizon.net> wrote in message news:9...

Display Time in Outlook
The time setting in my Outlook is one hour behind my actual time. I cannot determine how to change the time. Outlook is the only item that is incorrect. Other display times in operating system are correct. Thanks, Jodi ...

Date validation #3
hello everybody, i am new to excel , and i want to format a particular cell such that it accepts a date and the date should BE ONLY SATURDAY. If the date is not saturday a message box should appear and say "please enter the correct date". Please let me know step by step.As i am not comfortable using excel. Thanx, Ragini. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~ View and post usenet messages directly from http://www.ExcelForum.com/ Ragini, Use Data Validation, setup a custom criteria, and use a formula of =WEEKDAY(A1)=...

outlook freezes when viewing in day,week, month mode
Hi, WHen I navigate to the calendar function Outlook 'locks up' and does not respond. Waiting for the activity to proccess does not work and i have to close it down and re-open. However, if I change to view to the list mode this doesn't occur. This seems to have started happening only after loading Business Contact Manager. I have reloaded both but still have the same problem. Can anyone help. On 3/8/2010 10:19 PM, GT Query wrote: > Hi, WHen I navigate to the calendar function Outlook 'locks up' and does not > respond. Waiting for the activity to p...

Money 2007 -- QIF import
Good Evening! After a little trial and error, I am able to import account transactions from another system (not a bank statement, my actual register transactions) with little trouble except for the date format. (Before someone gets mad at me, I really don't think this has anything to do with my regional settings!) As recommended by an MVP from this forum, I open my CSV file with excel, then use a converter (add-in) called XL2QIF to create a qif output file. The actual "data" in a date field in my original csv file is "060106" (mm/dd/yy) which is June 1, 2006,...

PK and FK Displayed
I am a complete Visio newbie, and cannot find the answer I need in books or online help. I am trying to create ER diagrams from scratch, and not connected to real tables, using VEA. I have added tables ('Entities') to the form, connected them with a Relationship connector, and, in the Database Properties window I've assigned the end points to a Primary Key on the left and a Foreign Key on the right. But the model shows the connector as running between the top colums on both sides, whereas I want the keys to be in that upper box and provide the connector's end points. Wh...

Formulas are displayed, results are not
Hello, For some reason, when I enter a formula into a cell and press enter, the formula just stays there. Anyone know what I can do to show the results? I tried pressing Cntrl + `, but that didn't work. FYI, when I cut and paste a column from a separate workbook, that column works like normal (i.e., the formulas produce results). Thanks for any suggestions! Hi Mike, Maybe your cell is preformatted as Text. Try formatting to general then erase your = and type it in again. HTH Martin "Mike C" <js2k111@yahoo.com> wrote in message news:f699bcd4-ad82-4a88-9759-5638c147b...

Excel 2007 does start up right
I have been using Excel 2007 since about March with no problems. Recently I started experiencing a problem when the application is stated. It randomly (maybe 2 out of 6 times) does not open to the "grid" screen but rather a light blue screen with nothing on it except the Ready button in the upper left corner. If I click on that button I get the same drop down menus as I get when the application starts correctly and I click on the Ready button in the lower left corner. This has only been happening for about the last two weeks. If I just open it and close it several times withou...

pivot table label adding "2" to the end of a label name
Hi, I have a pivot table and sometimes it adds a "2" to the end of a row lable ie. "joes pizza" is displayed as "joes pizza2". the sorce data certanly doesn't include the "2" and it seems like it is trying to tell me some thing ;). It might be hapening after i do a "replace command" in the source data (replace "sams pizza" with joes Pizza"). any one experienced this? Cheers, The only time I've seen this is when I had multiple headers with the same name. If I were you, I'd check once more--don't forget to c...

calendar sometimes opens in month view
every once in a while (sorry that i can't be more precise), i find that clicking on calendar, under 'all folders' , causes it to open in month view. i can go back to inbox, and again click on calendar and get month view again. for most of a day. then it goes back to opening on current day. which it does most of the time. i don't remember if this happens after a reboot, standby, or just for no apparent reason. actually i prefer month view and wish i could make it open this way all the time. any ideas about what it happening here? ...

Stop displaying a line
I have a line graph/chart and it gets its values using a formula and the values of another column. However this poses a problem because if there is nothing in the targetted column the formula returns 0 cause the line to drop to the bottom, instead of casuing the line to just end until a value is added to the target column. How can I do this? Change your formula to use NA() if the cell is empty. For example: =IF(A1="",NA(),A1) To hide the resulting #N/A errors on the worksheet, you can use conditional formatting. There are instructions here: http://www.contextures.com/xlC...

Months old reconciled transactions reappear as unacknowledged after QIF import
Running Money Plus Deluxe. I do not have direct download from my CU so I have to import QIF files. Intermittentlly when I download the latest transactions, Money instead comes up with no new transactions, but unmatches some old ones. Ttoday, I had 4 unmatched transactions appear from June and July. In one case, the same transaction number downloaded previously from July 3 was listed as a probably match for an entry already there AND as a separate item One was reconciled and one was marked E (the one considered unmatched). As I write this I consider the possibility that the QIF file I am ...

Counting against a date
Hi I want to count the rows in a range 'Tests 1' AF3:AF1000=YES if the date in the range 'Tests 1' AD3:AD1000 is (<=) less than or equal to the date in B14 (current sheet) using the following formula: =IF($B14="","",(SUMPRODUCT(('Tests 1'!$AF$3:$AF$1000=YES)*('Tests 1'!AD$3:$AD1000<=$B14)))) unfortunately this returns an #N/A error I'm clearly missing something here so any tips or pointers would be appreciated. -- Steve Sometimes I think we're alone. Sometimes I think we're not. In either case, th...