| | |
getting data from one form to another.
Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Feb 2006
Posts: 30
Reputation:
Solved Threads: 0
i wondered if anyone could help me with this.
i have a button on a form (frmUpdateProduct). this button opens up another form (frmSelectSupplier). i have a listbox which gets all the supplier names from the access database, and assigns then with the Supplier ID (also from the database). here is the code for the listbox:
i need to get the supplier name/ supplier id, to be sent to a text box (frmUpdateProduct.TxtSupplier.text). how would i do this?
i have a button on a form (frmUpdateProduct). this button opens up another form (frmSelectSupplier). i have a listbox which gets all the supplier names from the access database, and assigns then with the Supplier ID (also from the database). here is the code for the listbox:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub form_activate() Set m_colSuppID = Nothing Set m_colSuppID = New Collection strSQL = "SELECT [supplier_ID], [SupplierName] FROM [Supplier]" With con .Open Set RP = .Execute(strSQL) End With With RP lstSupplier.Clear Do Until .EOF lstSupplier.AddItem "" & !supplierName m_colSuppID.Add CStr(!supplier_ID), "" & !SupplierName .MoveNext Loop .Close End With con.Close End Sub
i need to get the supplier name/ supplier id, to be sent to a text box (frmUpdateProduct.TxtSupplier.text). how would i do this?
2 ways :
You can have the Supplier data (Name, Id) as global variables. From form1 (SelectSupp) set the values of the globals and then open form2(UpdProduct). Then u can access the global variables from form2. Frankly, some programmers don't like to use globals, so the second method is better.
Declare a public function in form1 that shows the SuppName.
Public ShowSuppName() as String
ShowSuppName = lstSupplier.Text
End Function
Then call this function from form2 after it has been loaded
txtSupplier.text = form1.ShowSuppName()
You can have the Supplier data (Name, Id) as global variables. From form1 (SelectSupp) set the values of the globals and then open form2(UpdProduct). Then u can access the global variables from form2. Frankly, some programmers don't like to use globals, so the second method is better.
Declare a public function in form1 that shows the SuppName.
Public ShowSuppName() as String
ShowSuppName = lstSupplier.Text
End Function
Then call this function from form2 after it has been loaded
txtSupplier.text = form1.ShowSuppName()
![]() |
Similar Threads
- load data from access database into form (VB.NET)
- why isn't this booking form working. (ASP)
- How do I get the data collected in a VB form into specific locations in word 97 doc (Windows Software)
- Help with asp form will not display contact information (ASP)
- Login and retrieve user data from database (ASP.NET)
- How to acess data from database and display it form text in formatted way (ASP)
- please help! this is urgent> how to retrieve data to my tabpage without using data fo (C#)
- get posted form data in python (Python)
- Perl/CGI (Checking For Data) (Computer Science)
- Dialog Box alongwith Form (Visual Basic 4 / 5 / 6)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Views: 5694 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Visual Basic 4 / 5 / 6
* 6 429 2007 access activex add age append application basic beginner birth bmp c++ calculator cd cells.find click client code college column component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report retrieve save search sendbyte sites sort sql sql2008 sqlserver struct subroutine table tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





