Solved

How to get dept and name? Simple qn,urgent pls help!

Posted on 2006-11-07
8
240 Views
Last Modified: 2011-09-20
Hi All..
I have an urgent qn and I'm new to this.

I have 2 textfields and this is how I get the names thru the texfields. I need the sender and department. Only the 2 fields, how do I call for them??

And how come I get errors when i try to compile? it will say sName=Sender is an Error: expected function or variable?
Public Sub sName()
    sName = sender
End Sub
=================================

Dim strMessage

Public sender As String < ---------------
Public department As String < ---------------

Public Sub sName()
    sName = sender
End Sub
Public Sub DeptName()
    DeptName = department
End Sub
Private Sub txtDept_gotFocus()
    If txtDept.Text = "Department" Then
        txtDept.Text = ""
        department = txtDept.Text
    End If
   
End Sub

Private Sub txtDept_LostFocus()
    If txtDept.Text = "" Then
        txtDept.Text = "Department"
        department = txtDept.Text
    End If
   
End Sub

Private Sub txtName_gotFocus()
    If txtName.Text = "Sender" Then
        txtName.Text = ""
        sender = txtName.Text
    End If
End Sub

Private Sub txtName_LostFocus()
    If txtName.Text = "" Then
        txtName.Text = "Sender"
        sender = txtName.Text
    End If
End Sub

====================================

I'm using active X control to embed this form into outlook. however i need to get the fields and write it into the email body. Please anyone teach me how I can embed into the codes as below which is to be included in outlook. Please help urgent..thanks inadvance!

++++++++++++++++++++++++++++++++++++++++++

Dim strMessage
Dim strSubject
cYear = year(Date())
strSubject = " Christmas Card "&cYear

Function Item_Open()
    item.subject = strSubject
End Function


Function AddInfo()
      'colControls.sName        
      'colControls.DeptName      
      Set colControls = Item.GetInspector.ModifiedFormPages("Message")
           'If sender <> "" And _
       ' department <> "" Then
                strMessage = strMessage _
                & "Dear Clients & Friends" & vbCrLf _
                & vbCrLf _
                & "Season's greeings from the Management" & vbCrLf _
                & vbCrLf _
                & "http://www.oceantankers.com/xmas" & cYear & vbCrLf _
                & vbCrLf _
                & "Best regards" & vbCrLf _
                & vbCrLf _ *************(to include sender's name)
                & vbCrLf _*************(to include dept;s name)
            AddInfo = True
           'Else
           ' AddInfo = False
           'End If
     'Set objThisPage = Nothing
     Set colControls = Nothing
End Function

Function Item_Send()
       If AddInfo() = True then
       Item.subject = strSubject
       Item.body = strMessage
       Item.Display
       Item.MessageClass = "IPM.Note"
        End If    
End Function  
0
Comment
Question by:Yannie
8 Comments
 
LVL 12

Expert Comment

by:BobLamberson
ID: 17895441
If I understand what you are doing, all that you need is code in the

Dim strMessage

Public sender As String '< ---------------
Public department As String '< ---------------

Private Sub Text1_Change()

    sender = Text1.Text     ' this fills your variable 'sender'
    Label1 = sender     ' this demonstrates that it is producing a value and putting it into your variable

End Sub

Private Sub text2_change()

    department = Text2.Text ' this fills you variably 'department'
    Label2.Caption = department
End Sub

does this answer your question?
0
 

Author Comment

by:Yannie
ID: 17895689
Hi Bob,

I actually did it...
the code is actually below..under the gotFocus and lostFocus function as i pasted above..

I actually need to embed it into the second portion of my codes under the AddInfo() such that I can drag the sender and dept variable in...the problem here is i'm not sure how i can get the 2 variables in..

Function AddInfo()
   
      Set colControls = Item.GetInspector.ModifiedFormPages("Message")
          If sender <> "" And _               <----------------------how to get the public sender variable in here..
       ' department <> "" Then            <----------------------how to get the public dept variable in here..
                strMessage = strMessage _
                & "Dear Clients & Friends" & vbCrLf _
                & vbCrLf _
                & "Season's greeings from the Management" & vbCrLf _
                & vbCrLf _
                & "http://www.oceantankers.com/xmas" & cYear & vbCrLf _
                & vbCrLf _
                & "Best regards" & vbCrLf _
                & "sender" & vbCrLf _ <----------------------how to print  the public sender variable in here..
                & "dept" & vbCrLf _ <----------------------how to print the public dept variable in here..
            AddInfo = True
           'Else
           ' AddInfo = False
           'End If
       Set colControls = Nothing
End Function

 
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 17895713
Function AddInfo()
      Set colControls = Item.GetInspector.ModifiedFormPages("Message")
          If sender <> "" And department <> "" Then        
                strMessage = strMessage _
                & "Dear Clients & Friends" & vbCrLf _
                & vbCrLf _
                & "Season's greeings from the Management" & vbCrLf _
                & vbCrLf _
                & "http://www.oceantankers.com/xmas" & cYear & vbCrLf _
                & vbCrLf _
                & "Best regards" & vbCrLf _
                & sender & vbCrLf _
                & department & vbCrLf _
            AddInfo = True
           'Else
           ' AddInfo = False
           'End If
       Set colControls = Nothing
End Function


0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 17895716
Here is an example of combining strings:

dim strMessage as string
dim strName as string
dim strFinal as string

strName = "Brian"
strMessage = "Hello, my name is "
strFinal = strMessage & strName
MsgBox(strFinal)
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 17895721
Or you could do something like this:

dim strMessage as string
dim strUser as string
dim strProgrammer as string

strProgrammer = "Brian"
strMessage = "Hello %user_name% my name is %programmer_name%"
strUser = inputbox("Whats your name?")
strMessage = replace(strMessage,"%user_name%",strUser)
strMessage = replace(strMessage,"%programmer_name%",strProgrammer)

msgbox strMessage



Hope that helps...

Brian
0
 

Author Comment

by:Yannie
ID: 17904760
Hi i sort of got the ans already..

I have to add
Set fmCtl = Item.GetInspector.ModifiedFormPages("Message").Controls("CardFormCtl1")
      dept = fmCtl.DeptName
 under the AddInfo() and this works! Thanks guys!
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17964590
PAQd, 500 points refunded.

DarthMod
CS Moderator
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now