MS Schedule/Form Problems

thegoose

New member
Local time
Today, 17:57
Joined
Jan 20, 2003
Messages
5
Wonder if anyone can help me, I am not that experienced with Access and I have been asked to design an appointment dbase..gulp!

I am using the code from this help page currently and have modified it slightly as I wish to use the form as Data entry and ONLY update the current record entered. I Cannot run the following code without the "type mismatch" error? anyone have any ideas?

details at link below:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;149078

Code:
Function AddAppts()
On Error GoTo Command1_Click_error

Dim objApp As Object, objSched As Object
Dim objTable As Object, objItem As Object
Dim db As Database, rs As Recordset, UserName As _
String
Dim startDateTime As Variant, endTime As Variant, apptText As _
Variant

' Connect to Schedule+ and check if user is logged on or not
' logged on.
Set objApp = CreateObject("SchedulePlus.Application")
If Not objApp.LoggedOn Then
UserName = InputBox("Please enter your profile name." & _
Chr(13) & Chr(13) & "Example: Nancy Davolio")
If UserName = "" Then
Set objApp = Nothing
Exit Function
End If
objApp.Logon UserName, " ", True
End If
Set objSched = objApp.ScheduleLogged
Set objTable = objSched.SingleAppointments

' Create a recordset from the Conference Sessions table.
Set db = CurrentDb()
Set rs = db.OpenRecordset("Conference Sessions")

'Add new record
rs.AddNew
startDateTime = rs!Date & " " & rs![Start Time]
endTime = rs!Date & " " & rs![End Time]
apptText = rs!Session



'Create a new appointment and set its properties.
Set objItem = objTable.New
objItem.SetProperties Text:=apptText, _
BusyType:=CLng(1), start:=CDate(startDateTime), _
End:=CDate(endTime)
rs.MoveNext


' Log off Schedule+ and release the objects.
objApp.logoff
Set objApp = Nothing
Set objSched = Nothing
Set objItem = Nothing
Set objTable = Nothing

MsgBox "rs![Session]", "'s appointment was added to Schedule+."
Exit Function

Command1_Click_error:
If Err = -2147221229 Or Err = 5 Or Err = 3270 Then
MsgBox "Operation canceled."
Else
MsgBox "Error: " & Err & " " & Error
End If
Exit Function

End Function
 
Try going into the code window, Go to Tools-> References.
Look for Microsoft DAO 3.x object library & check it on in the list.
 
Will do, Many thanks
 
it is ticked, tried it again, but no good... not very experienced am I missing something?
 
Just compiled it locally & looks fine.. Do you know what line you are getting the error on?

Also, just out of curiosity,
try Dim db as DAO.Database & dim rs as DAO.RecordsSet

instead of the current dim db as database & dim rs as Recordset
 
Sorry Still can't get it to run, Doesn't tell me that I actually have error in the code, just a type mismatch, but I have checked all the buttons and cannot figure it out. The form simply has "Session,date,start time,end time" as fields and add appointments Cmd button with AddAppt as it's onclick procedure. this is my code:

Function AddAppts()
On Error GoTo Command1_Click_error

Dim objApp As Object, objSched As Object
Dim objTable As Object, objItem As Object
Dim db As DAO.Database, rs As DAO.Recordset, UserName As _
String
Dim startDateTime As Variant, endTime As Variant, apptText As _
Variant

' Connect to Schedule+ and check if user is logged on or not
' logged on.
Set objApp = CreateObject("SchedulePlus.Application")
If Not objApp.LoggedOn Then
UserName = InputBox("Please enter your profile name." & _
Chr(13) & Chr(13) & "Example: Nancy Davolio")
If UserName = "" Then
Set objApp = Nothing
Exit Function
End If
objApp.Logon UserName, " ", True
End If
Set objSched = objApp.ScheduleLogged
Set objTable = objSched.SingleAppointments

' Create a recordset from the Conference Sessions table.
Set db = CurrentDb()
Set rs = db.OpenRecordset("Conference Sessions ")

' Add Appointment
rs.AddNew
startDateTime = rs!Date & " " & rs![start time]
endTime = rs!Date & " " & rs![end time]
apptText = rs!Session

' Create a new appointment and set its properties.
Set objItem = objTable.New
objItem.SetProperties Text:=apptText, _
BusyType:=CLng(1), Start:=CDate(startDateTime), _
End:=CDate(endTime)

rs.MoveNext


' Log off Schedule+ and release the objects.
objApp.logoff
Set objApp = Nothing
Set objSched = Nothing
Set objItem = Nothing
Set objTable = Nothing

MsgBox " appointments were added to Schedule+."
Exit Function

Command1_Click_error:
If Err = -2147221229 Or Err = 5 Or Err = 3270 Then
MsgBox "Operation canceled."
Else
MsgBox "Error: " & Err & " " & Error
End If
Exit Function

End Function
 
P.S However when I run the code without the "rs.AddNew" line, it works, but always imports the first appointment into Schedule, not the current one on the form!!
 

Users who are viewing this thread

Back
Top Bottom