View Single Post
  #6  
Old May 13th, 2010, 11:11 AM posted to microsoft.public.access.forms
XPS350
external usenet poster
 
Posts: 69
Default Add consecutive dates w/ command button & parameter boxes

On 13 mei, 00:33, Flopbot wrote:
Thank you Groeten & Karl for sharing your knowledge of Access with others! *

I’m playing around with Groeten’s suggestion (since his was first) and I
think it’s definitely in line with what I’m looking for (although it didn’t
work). *I did some more searching on the forums and found something about
InputBoxes which sounds ideal. *I tried one and it popped up a box to enter
my date. *Since I don’t know code, I’m sure I’ve butchered the following (it
doesn’t work), but am I at all close?

Private Sub Add_One_Month_DblClick()

* * Dim EventCount As Byte
* * Dim StartDate As String

* * StartDate = InputBox("Please Select a StartDate", "CUSTOMER SELECTION")
* * For EventCount = 1 To 31
* * DoCmd.RunSQL "INSERT INTO [SubFrm Vol Opportunities] (Event Date)
VALUES(#" & DateAdd("m", EventCount - 1, [StartDate]) & "#)"
* * Next

End Sub


I think you are close. Looking at your code it looks like you try to
insert data into a (sub) form. That is not possible. Forms show data
that is stored in tables. So you have to store data into a table
first. That is what DoCmd.RunSQL "INSERT INTO..." is doing. Where youy
have [SubFrm Vol Opportunities] there should be the name of a table.

One more thing about the inputbox. You cannot be sure that what is
entered is a (valid) date. So you have check that (function IsDate).
That is why I prefer to use a form field. You can define it as a date
and thus make sure a valid date is returned.


Greetings (or "Groeten" in dutch)

PETER

http://access.xps350.com