Outlook 2003 Saving into a textbox when form closes

Status
Not open for further replies.
D

Daniel

Ok, when the Post closes it saves everything in the Post to an Access database and its suppose to grab the autonumber from the access database and place it in a textbox on the Post. But when I open the Post the textbox with the ID number is empty, How do I save the Number when the Post closes?

Function OpenAccessDB(strDBPath)

Const adStateOpen = 1

Dim objADOConn

Dim strConn, UID, PWD

UID = ""

PWD = ""

On Error Resume Next

strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _

"Data Source=" & strDBPath & "; " & _

"User ID=" & UID & "; " & _

"Password=" & PWD & "; "

Set objADOConn = CreateObject("ADODB.Connection")

objADOConn.Open strConn

If (Err = 0) And (objADOConn.State = adStateOpen) Then

Set OpenAccessDB = objADOConn

Else

Set OpenAccessDB = Nothing

End If

Set objADOConn = Nothing

End Function

'----------------------------------------------------------- ------------------------------------------------------------ -

Function GetNewNumber()

Const adLockOptimistic = 3

Const adOpenDynamic = 2

Dim adoConn 'As ADODB.Connection

Dim rstHelpDesk 'As ADODB.Recordset

Dim strPath 'As String

Dim strSQL 'As String

Dim strName 'As String

Dim FormID

' ### USER OPTION ###

' path to HelpDesk database

strPath = "C:\HelpDesk\HelpDesk.mdb"

Set adoConn = OpenAccessDB(strPath)

strSQL = "SELECT * FROM [HelpDesk];" 'was "SELECT [ID] FROM HelpDesk;"

Set rstHelpDesk = CreateObject("ADODB.Recordset")

rstHelpDesk.Open strSQL, adoConn , adOpenDynamic, adLockOptimistic

If Item.UserProperties("ID") = "" Then

rstHelpDesk.AddNew

rstHelpDesk.Fields("ComputerName") = Item.UserProperties("Computer Name")

rstHelpDesk.Fields("Date") = Item.UserProperties("Date")

rstHelpDesk.Fields("AVG") = Item.UserProperties("AVG")

rstHelpDesk.Fields("Mas200") = Item.UserProperties("Mas200")

rstHelpDesk.Fields("Unexplained Popups") = Item.UserProperties("Unexplained Popups")

rstHelpDesk.Fields("Virus/Trojans") = Item.UserProperties("Virus/Trojans")

rstHelpDesk.Fields("Windows") = Item.UserProperties("Windows")

rstHelpDesk.Fields("Other") = Item.UserProperties("Other")

rstHelpDesk.Fields("Other Text") = Item.UserProperties("Other2")

rstHelpDesk.Fields("Description") = Item.UserProperties("Description")

rstHelpDesk.Fields("Was Anything Installed") = Item.UserProperties("Installed")

Else

FormID = "ID = " & Item.UserProperties("ID")

rstHelpDesk.Find FormID

rstHelpDesk.Fields("how to") = Item.UserProperties("How to")

rstHelpDesk.Fields("did it work?") = Item.UserProperties("Option")

rstHelpDesk.Fields("if no") = Item.UserProperties("If no")

rstHelpDesk.Fields("Is this Issue Resolved?") = Item.UserProperties("Option2")

rstHelpDesk.Fields("Notes") = Item.UserProperties("Note")

End if

rstHelpDesk.Update

Item.UserProperties("ID")= rstHelpDesk.Fields("ID") <-- doesn't save

Msgbox Item.UserProperties("ID") <--the messagebox does give me a number

rstHelpDesk.Close

adoConn.Close

Set adoConn = Nothing

Set rstHelpDesk = Nothing

End Function

'----------------------------------------------------------- ------------------------------------------------------------ -

Function Item_Close()

Dim Save

Save=msgbox("Do you want to Save this Form to the Database or Cancel?",1,"Save?")

If Save = VbOk Then

GetNewNumber()

End If

End Function.
 
If the item is closing because no previous changes were made to it, the item

isn't going to be saved. You may need to change the logic and require users

to save the item in order to get a new number, not just close it.

Sue Mosher

"Daniel" <donotreply2me[at]yahoo[dot]com> wrote in message

news:OGnDYVxjKHA.5608@TK2MSFTNGP05.phx.gbl...
> Ok, when the Post closes it saves everything in the Post to an Access
> database and its suppose to grab the autonumber from the access database
> and place it in a textbox on the Post. But when I open the Post the
> textbox with the ID number is empty, How do I save the Number when the
> Post closes?

> Function OpenAccessDB(strDBPath)
> Const adStateOpen = 1
> Dim objADOConn
> Dim strConn, UID, PWD
> UID = ""
> PWD = ""
> On Error Resume Next
> strConn = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
> "Data Source=" & strDBPath & "; " & _
> "User ID=" & UID & "; " & _
> "Password=" & PWD & "; "
> Set objADOConn = CreateObject("ADODB.Connection")
> objADOConn.Open strConn
> If (Err = 0) And (objADOConn.State = adStateOpen) Then
> Set OpenAccessDB = objADOConn
> Else
> Set OpenAccessDB = Nothing
> End If
> Set objADOConn = Nothing
> End Function

> '----------------------------------------------------------- ----------------------------------------------------------> -

> Function GetNewNumber()
> Const adLockOptimistic = 3
> Const adOpenDynamic = 2
> Dim adoConn 'As ADODB.Connection
> Dim rstHelpDesk 'As ADODB.Recordset
> Dim strPath 'As String
> Dim strSQL 'As String
> Dim strName 'As String
> Dim FormID
> ' ### USER OPTION ###
> ' path to HelpDesk database
> strPath = "C:\HelpDesk\HelpDesk.mdb"
> Set adoConn = OpenAccessDB(strPath)
> strSQL = "SELECT * FROM [HelpDesk];" 'was "SELECT [ID] FROM HelpDesk;"
> Set rstHelpDesk = CreateObject("ADODB.Recordset")
> rstHelpDesk.Open strSQL, adoConn , adOpenDynamic, adLockOptimistic

> If Item.UserProperties("ID") = "" Then
> rstHelpDesk.AddNew
> rstHelpDesk.Fields("ComputerName") = Item.UserProperties("Computer Name")
> rstHelpDesk.Fields("Date") = Item.UserProperties("Date")
> rstHelpDesk.Fields("AVG") = Item.UserProperties("AVG")
> rstHelpDesk.Fields("Mas200") = Item.UserProperties("Mas200")
> rstHelpDesk.Fields("Unexplained Popups") =
> Item.UserProperties("Unexplained Popups")
> rstHelpDesk.Fields("Virus/Trojans") = Item.UserProperties("Virus/Trojans")
> rstHelpDesk.Fields("Windows") = Item.UserProperties("Windows")
> rstHelpDesk.Fields("Other") = Item.UserProperties("Other")
> rstHelpDesk.Fields("Other Text") = Item.UserProperties("Other2")
> rstHelpDesk.Fields("Description") = Item.UserProperties("Description")
> rstHelpDesk.Fields("Was Anything Installed") =
> Item.UserProperties("Installed")
> Else
> FormID = "ID = " & Item.UserProperties("ID")
> rstHelpDesk.Find FormID
> rstHelpDesk.Fields("how to") = Item.UserProperties("How to")
> rstHelpDesk.Fields("did it work?") = Item.UserProperties("Option")
> rstHelpDesk.Fields("if no") = Item.UserProperties("If no")
> rstHelpDesk.Fields("Is this Issue Resolved?") =
> Item.UserProperties("Option2")
> rstHelpDesk.Fields("Notes") = Item.UserProperties("Note")

> End if

> rstHelpDesk.Update
> Item.UserProperties("ID")= rstHelpDesk.Fields("ID") <-- doesn't save
> Msgbox Item.UserProperties("ID") <--the messagebox does give me a number
> rstHelpDesk.Close
> adoConn.Close
> Set adoConn = Nothing
> Set rstHelpDesk = Nothing
> End Function

> '----------------------------------------------------------- ----------------------------------------------------------> -

> Function Item_Close()
> Dim Save
> Save=msgbox("Do you want to Save this Form to the Database or
> Cancel?",1,"Save?")

> If Save = VbOk Then
> GetNewNumber()
> End If

> End Function.
 
Is there a way to make a button that will save and then post the message?.
 
The object browser (F2 in VBA) is your friend. Try calling Item.Post.

Sue Mosher

"Daniel" <donotreply2me[at]yahoo[dot]com> wrote in message

news:%239chN0xjKHA.2184@TK2MSFTNGP04.phx.gbl...
> Is there a way to make a button that will save and then post the message?.
>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
C Exchange 2003 - Outlook 2003 - Calendar entries saving over each other Using Outlook 2
D Outlook 2003 saving option button Outlook VBA and Custom Forms 1
D Wishlist How to use 'app password' in Outlook 2003 after Google pulled plug on "less secure apps" Using Outlook 2
J Outlook 2003 .pst Will Not Restore Completely to Outlook 2019 Using Outlook 5
D Outlook 2003 Mail Fails Using Outlook 1
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 4
V Outlook 2003 and Windows 11 Using Outlook 4
glnz Moving from Outlook 2003 to MS365 Outlook - need basics Using Outlook 4
I Outlook 2003 shows html code when To: field is empty Using Outlook 7
B Outlook 2003 email sending & receiving suddenly stopped working Using Outlook 3
H Outlook 2003 find by "has attachment" Using Outlook 1
glnz How set up new IMAP on Outlook-Office 365 and merge in pst from Outlook 2003 for same two email accounts? Using Outlook 5
P Import Categories from Outlook 2003 Using Outlook 8
V Outlook 2003 problem with Windows 10 Creators Update 1709 Using Outlook 0
M Outlook 2003 pictures - some visible, some not Using Outlook 0
S Outlook 2003 to Outlook 2013 pst file Using Outlook 5
O Memory Leak in Outlook 2003 Using Outlook 3
W Changing looks of emails in Outlook 2003 Using Outlook 0
O Outlook 2003 can't send, but settings seem OK Using Outlook 1
P URL Hyperlink not working correctly in Outlook 2003 Using Outlook 10
O Outlook 2003 can't open contacts. Using Outlook 2
O Promoting Outlook 2003 User Templates Using Outlook 1
O W-a-a-y too many PSTs (Outlook 2003) Using Outlook 0
J Outlook 2003-2010 PST Field Editor Using Outlook 1
P Outlook 2003 - Do I need a new profile? Using Outlook 2
E Want to Import Outlook 2003 pst files to later version Using Outlook 6
A error message outlook 2003 Using Outlook 1
B Seeking advice now Outlook 2003 is unsupported by Exchange Using Outlook 4
O Change Debit to Credit in Outlook 2003? Using Outlook 1
J problems downloading POP3 emails to Outlook 2003 Using Outlook 1
G Outlook 2003 VBA Won't Run In Outlook 2010 Outlook VBA and Custom Forms 4
P Outlook 2003 - possible to recreate corrupt account? Using Outlook 3
Calvyn Outlook 2003 cannot import .vcs subject Using Outlook 1
T Query about one aspect of migrating .pst files from Outlook 2003 to Outlook 2013 Using Outlook 5
C Outlook 2003 contacts Using Outlook 1
G Configuring Outlook 2003 for Gmail with both pop3 & imap4 accounts Using Outlook 1
M HELP--Extract Data from 2003 outlook transfer to excel spreadsheet Using Outlook 1
V Outlook 2003 editing problem Using Outlook 4
X Outlook 2003 not sending all of the new email message Using Outlook 1
2 How to use outlook 2003 calendar in always offline mode Using Outlook 0
G Outlook 2003 I need to move email to folder based on subject, using wild card Using Outlook 0
G outlook 2013 - Open In Outlook 2003 Using Outlook 1
A Exchange 2003 Outlook 2010 64 Bit- AutoDiscover Connection Err - Certificate Exchange Server Administration 9
T Use Outlook 2003 with Office 2013 Using Outlook 1
D Outlook 2003 contact folder opend in scrolled down position Using Outlook 2
O Need advice ASAP! Outlook 2003. Using Outlook 1
H Custom Contact form not working in Outlook 2003 Using Outlook 3
O Outlook 2003 forms problem Using Outlook 3
O Duplicate folders in Outlook 2003 Using Outlook 3
O Moving OUtlook 2003 from bad XP to Win 7 Pro 64 -- URGENT! Using Outlook 8

Similar threads

Back
Top