Calendar Question

  • Thread starter Beto1967 via AccessMonster.com
  • Start date
B

Beto1967 via AccessMonster.com

Hi
I found this coding in the web that produces a Calendar ..(Perfect) What I
need help with.. Since the boxes are unbound how can I save the data that is
inserted for the partculiar days of the Calendar for historical purposes or
generate a reports and be in a calendar format ?(E.G. What was done on
certain days ) Enclosed is the Code
TIA

Private Sub form_open(Cancel As Integer)
Me![FIRSTDATE] = Date
Call filldates
Dim selday As Integer, DateSelected As Variant
End Sub

Private Function filldates()
Dim curday As Variant, curbox As Integer
curday = DateSerial(Year(Me![FIRSTDATE]), Month(Me![FIRSTDATE]), 1) 'first
day of month
curday = DateAdd("d", 1 - Weekday(curday), curday) 'back to sunday
For curbox = 0 To 41 'need to loop thru 42 textboxes
Me("D" & curbox) = Day(curday)
Me("D" & curbox).Visible = False
If Month(curday) = Month(Me!FIRSTDATE) Then Me("D" & curbox).Visible = True
curday = curday + 1 'nextday
Next curbox
End Function
 
B

Biz Enhancer

Is there any reason you cannot reference your unbound field in an SQL
statement?
e.g. Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"

HTH,
Nick.
 
B

Beto1967 via AccessMonster.com

Hi, BizEnhancer
Where would I put the SQL in the form ? or would I create a query and make
refereance to the form? Thanks again

Biz said:
Is there any reason you cannot reference your unbound field in an SQL
statement?
e.g. Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"

HTH,
Nick.
Hi
I found this coding in the web that produces a Calendar ..(Perfect) What I
[quoted text clipped - 22 lines]
Next curbox
End Function
 
B

Biz Enhancer

You could put the SQL statement under the "on Click" event on a button.
e.g. a Command button named CmdSave
Sub CmdSave_Click()
Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"
End Sub

It is often easier to create the SQL statement in the Query Design view and
then copy the SQL statement into the VBA code

Does that help?

Nick.

Beto1967 via AccessMonster.com said:
Hi, BizEnhancer
Where would I put the SQL in the form ? or would I create a query and make
refereance to the form? Thanks again

Biz said:
Is there any reason you cannot reference your unbound field in an SQL
statement?
e.g. Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"

HTH,
Nick.
Hi
I found this coding in the web that produces a Calendar ..(Perfect) What I
[quoted text clipped - 22 lines]
Next curbox
End Function
 
B

Beto1967 via AccessMonster.com

The code works thanks . it only appends the date (#) I would need the data
that was put in for that date .E.G report 1, report2, meeting.. when it
appends its only the date. Would you know of a way to create a calendar that
I can type in what needs to get done for that date or month view? The code I
am using does generate Thanks for assistance Biz Enhancer.

Biz said:
You could put the SQL statement under the "on Click" event on a button.
e.g. a Command button named CmdSave
Sub CmdSave_Click()
Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"
End Sub

It is often easier to create the SQL statement in the Query Design view and
then copy the SQL statement into the VBA code

Does that help?

Nick.
Hi, BizEnhancer
Where would I put the SQL in the form ? or would I create a query and make
[quoted text clipped - 15 lines]
 
B

Biz Enhancer

If you are working on top of an Access table you could use an UPDATE query to
add the date value to the current record;
UPDATE sometable SET sometable.datefield = " & x & " _
WHERE(((sometable.datefield) = Me.recordID));

If your pushing data to an SQL server just add more fields to the INSERT
statement. You can reference then using Dim statements if you choose or just
put the field reference directly in the sql statement.

Nick.
Beto1967 via AccessMonster.com said:
The code works thanks . it only appends the date (#) I would need the data
that was put in for that date .E.G report 1, report2, meeting.. when it
appends its only the date. Would you know of a way to create a calendar that
I can type in what needs to get done for that date or month view? The code I
am using does generate Thanks for assistance Biz Enhancer.

Biz said:
You could put the SQL statement under the "on Click" event on a button.
e.g. a Command button named CmdSave
Sub CmdSave_Click()
Dim x as String
x = me.unboundtextbox

DoCmd.RunSQL "INSERT INTO sometable (datefield) SELECT " & x & ";"
End Sub

It is often easier to create the SQL statement in the Query Design view and
then copy the SQL statement into the VBA code

Does that help?

Nick.
Hi, BizEnhancer
Where would I put the SQL in the form ? or would I create a query and make
[quoted text clipped - 15 lines]
Next curbox
End Function
 
B

Beto1967 via AccessMonster.com

Thanks Biz Enhancer
For your assistance it help out

Biz said:
If you are working on top of an Access table you could use an UPDATE query to
add the date value to the current record;
UPDATE sometable SET sometable.datefield = " & x & " _
WHERE(((sometable.datefield) = Me.recordID));

If your pushing data to an SQL server just add more fields to the INSERT
statement. You can reference then using Dim statements if you choose or just
put the field reference directly in the sql statement.

Nick.
The code works thanks . it only appends the date (#) I would need the data
that was put in for that date .E.G report 1, report2, meeting.. when it
[quoted text clipped - 23 lines]
 

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

Similar Threads

Too Many Dates 1
Dateserial function 1
Search Listbox vs Table Query 1
Code won't work 3
Set Date Code Probem 4
calender problem 0
automatically populating dates in a userform 2
I am going mad!! 10

Top