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

Searching record in another form

Status
Not open for further replies.

davidmcolaco

Technical User
Aug 1, 2005
102
PT
Hi,

I have a form where I have a inputbox to get a value from the user and then open another form and open it on the number of record that the user entered.
The value is passed ok to the other form, because I made a msgbox and it shows the correct number that the user inserted. The problem is that the form doesn't open in the correct record, opens in a empty record.

Bellow I insert the code so that anyone can help me with this.

Pendente = InputBox("Insira o Nº Trabalho que deseja encontrar:")

TrabalhosRS.Close
m_oConn.Close
Unload Me
Trabalhos.Show
With Trabalhos.TrabalhosRS
.MoveFirst
.Find "t_empresa LIKE '%" & Pendente & "%'"
End With
MsgBox "Numero: " & Pendente

Thanks in advance...
 
Hi,

Maybe this will help or at least give you some ideas. If your passing values I would dimension Pendente as a Public variable in a bas moduel.
In file Public.Bas
Option Explicit
Public Pendente As String

You'll need to put something like this in a procedure such as form_Load on form2.
Form2 Code
Option Explicit
Dim m_oConn As adodb.connection
Dim TrabalhosRS AS adODB.Recordset

Sub Form2_Load()
Set TrabalhosRs = New ADODB.Recorset
Set m_oConn = New adodb.connection
m_0Conn.Open "Connection string goes here"
TrabalhosRs.Connection = m_oConn
TrabalhosRs.Open "Select * From YourTable"
Call FilterRS
End SUb


Sub FilterRS()
With TrabalhosRS
.MoveFirst
.Find "t_empresa LIKE '%" & Pendente & "%'"
End With
MsgBox "Numero: " & Pendente
End Sub

I'm assuming there are possibly text box controls on the form where your expecting to see a record displayed? Are these textbox controls bound to TrabalhosRS? IF not you'll need to load their values with something like this in the procedure FilterRS after the With statement.

text1 = TrabalhosRS("YourFieldName")
text2 = TrabalhosRS("YourFieldName2")

That's all the time I've got today. Good Luck.

TallOne


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top