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

Using Calendar on a Form 1

Status
Not open for further replies.

jahlmer

Technical User
Aug 23, 2000
143
US
Hi,

I inserted an ActiveX control on my form. It is Calendar Control 8.0 (from Access 97).. I've got a field in my table that I would like the selected date from the calendar to be inserted into. How is this done?

Thanks in advance for your time and help.

 
I have access 2002 wich installed calendar 10.0 but it should be the same.


strSql = "INSERT INTO myTable " & _

if the field type is varchar then
"SET myField = '" & Calendar1.Value & "'"

if the field type is date then
"SET myField = #" & calendar1.Calue & "#"

connObj.Execute(strSql)

is this what you where asking for?
HTH
Alcar
 
The Calendar V10.0 object does not supply week views... only the entire month.
Alcar
 
If you want to do this without the hastle of an ActiveX control, see faq702-639 Jim Lunde
compugeeks@hotmail.com
Custom Application Development
 
Hello Alcar,

Thanks for the post. I am quite a novice and need to know where to insert the code you provided on my form.. Is it using the onClick event for a save button?

Tx again
 

Correct. I am assuming you have a button that will insert the data in the field.
What I wrote is the SQL Statement you will send to the connection object (db object) to make that insert.
hth
Alcar
 
Alcar,

Thanks again for the info.

Here's what I ended up with, but it is giving me some errors, and highlights SET...

(btw, is "my" in your example supposed to be used for something?)

Private Sub Save_Click()
strSql = "INSERT INTO tblEvents-NotOwner " & _
SET FollowupDate = #" & calendar1.value & "#
connObj.Execute (strSQL)

On Error GoTo Err_Save_Click


DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Exit_Save_Click:
Exit Sub

Err_Save_Click:
MsgBox Err.Description
Resume Exit_Save_Click

End Sub
 
Forgive me, in these days it's difficult here to remain fresh minded....

the correct syntax is this:

strSql = "INSERT tblEvents-NotOwner (FollowupDate) " & _
"VALUES('" & calendar1.value & "')"

sorry about that =)

Alcar
 
Ok, I am assuming that calendar1 is the NAME of each calendar (it didnt' work the other way around), and so I changed it... but am getting an error still... It highlights strSQL and a "compile error: variable not defined" ..

As you can see, I'm using 3 calendars in my form...

save is the name of my button
rest speaks for itself.

Private Sub Save_Click()
strSQL = "INSERT tblEvents2 (DateFollwup1) " & _
"VALUES('" & ActiveXCtl4.Value & "')"
strSQL = "INSERT tblEvents2 (DateFollwup2) " & _
"VALUES('" & ActiveXCtl9.Value & "')"
strSQL = "INSERT tblEvents2 (DateFollwup3) " & _
"VALUES('" & ActiveXCtll0.Value & "')"
End Sub
 
Also, I don't know if this makes a difference but this is a local database that is not running on an SQL server.
 
SQL is used without the need for SQL Server,
Access uses SQL throughout your database to retrieve the recordset that you request.

I recommend selecting 'SQL View' within the design of one of your database queries as an example.

I may not have explained this very well, and if not please feel free to clarify :I

 
Are you sure you didn't miss-spell something??

strSQL = "INSERT tblEvents2 (DateFollwup1b) " & _
"VALUES('" & ActiveXCtl4.Value & "')"

and after every single line of sql you have to execute it like this:

dbobject.execute strSql

check the syntax of the cariables
 
The last calendar reference looks like it may be wrong, L0 instead of 10 ?

strSQL = "INSERT tblEvents2 (DateFollwup3) " & _
"VALUES('" & ActiveXCtll0.Value & "')"

This is a guess, as I haven't seen the form/controls.

SunTsu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top