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

updating text field based on a Combo box selection?

Status
Not open for further replies.

sarahjane28

IS-IT--Management
Oct 23, 2002
14
US
I am just starting to use VB and have no clue what I am doing, I currently have a combo box that is filled from my database. Now what I don't know how to do is call the function to populate the text boxes based on the user changing the selection in the combox.

Here is my code, Thank you so much! I don't know what I would do without this board : )


Function Item_Open()

Dim myconn, rs, SQL
Dim MyPage
Dim String
Dim Box1

'Set MyPage = Item.GetInspector.ModifiedFormPages("CustomerInformation")
Set myconn = CreateObject("ADODB.Connection")
myconn.Open "Provider=SQLOLEDB;Data Source=Sutherland3;UID=Sa;PWD=;DATABASE=cmf"
Set rs = CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM Incident"
rs.Open SQL, myConn, adOpenDynamic,, adCmdText

if not( rs.eof and rs.bof ) then
do until rs.eof
MyString = MyString & rs("IncidentID") & ";"
rs.MoveNext
loop
end if

' Sets the name of page on the form (P.2)
Set MyPage = Item.GetInspector.ModifiedFormPages("CustomerInfo")
' Sets Control to a list box called ListBox1.
Set box1 = MyPage.Controls("ComboBox1")
' Assign values to the list box.
Box1.PossibleValues = MyString

rs.close

End Function
'*********************************************************************************

Function UpdateInformation()
Dim olemsession
Dim MyPage
Dim rs
Dim IncidID

On Error Resume Next

Set MyPage = Item.GetInspector.ModifiedFormPages("CustomerInfo")
Incid = Mypage.Combobox1.value


'----------------------------
'Adding values to Spreadsheet
'----------------------------
'set up path to database
'-----------------------
Set myconn = CreateObject("ADODB.Connection")
myconn.Open "Provider=SQLOLEDB;Data Source=Sutherland3;UID=Sarah;PWD=;DATABASE=cms"
Set rs = CreateObject("ADODB.Recordset")
SQL = "SELECT * FROM customerincident WHERE Incidentid = " & Incid
rs.Open SQL, myConn, adOpenDynamic,, adCmdText



'---------------------------------
'insert info on spreadsheet
'---------------------------------

MyPage.CustomerName.value = rs("Name")
MyPage.Address1.value = rs("Addr1")
MyPage.Address2.value = rs("Addr2")
MyPage.City.value = rs("City")
MyPage.State.value = rs("State")
MyPage.Zip.value = rs("Zip")
MyPage.Phone.value = rs("Phone1")
MyPage.Fax.value = rs("Fax1")
MyPage.Description.value = rs("Incident")
MyPage.Solution.value = rs("Solution")



rs.close

End Function


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top