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
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