Retrieving data from Access Table

R

requeth

Good morning internet community,

I am using Access 2000, and I am trying to do something that shouldnt
be as hard as it's appearing. I have data entry boxes to input data and
store into access tables. Then on a separate tab I have a subform that
I wish to display the data (view only). I have a search box for a 6
digit number, and when I click the button, I want it to do an SQL query
to select field1 from table1 where field2 = mysearchtext. Then I want
the output from that to go into the box that will be display only let's
say mysearchresultstext. I at first tried doing the SQL query in VB,
since I am more familiar with VB then I am with the Access GUI, but all
I could return was the actual SQL string instead of the processed
results. If I run a query using the GUI, it pops up a query screen with
the results, but I can not get it to a) stop showing the query results
and b) put the results into mysearchresultstext. Getting the data in is
so simple, that I know I'm putting the cart before the horse here. Any
ideas on what I'm doing wrong? If I can even get the query results to
save to a variable I can manipulate that in VB, but I cant even get it
to do that.
 
D

David PONDA

Hi,
Try this code in your main form module :

Private Sub mysearchtext_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[field2] = '" & Me![mysearchtext] & "'"
Me.Bookmark = rs.Bookmark
End Sub
 
R

requeth

That didnt seem to work, on the other hand it didnt throw up an error
either so who knows what it's doing with it ;). I currently have my
project configured to use the SQL query inside of Access, should I use
this or manually program it into VB? I'm not sure how access and VB are
working togeather on this, but unless it defines a recordset itself to
run, I'm not doing it. I wish I could see what it's code is after the
query runs so I could modify it, is this possible?

David said:
Hi,
Try this code in your main form module :

Private Sub mysearchtext_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[field2] = '" & Me![mysearchtext] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Good morning internet community,

I am using Access 2000, and I am trying to do something that shouldnt
be as hard as it's appearing. I have data entry boxes to input data and
store into access tables. Then on a separate tab I have a subform that
I wish to display the data (view only). I have a search box for a 6
digit number, and when I click the button, I want it to do an SQL query
to select field1 from table1 where field2 = mysearchtext. Then I want
the output from that to go into the box that will be display only let's
say mysearchresultstext. I at first tried doing the SQL query in VB,
since I am more familiar with VB then I am with the Access GUI, but all
I could return was the actual SQL string instead of the processed
results. If I run a query using the GUI, it pops up a query screen with
the results, but I can not get it to a) stop showing the query results
and b) put the results into mysearchresultstext. Getting the data in is
so simple, that I know I'm putting the cart before the horse here. Any
ideas on what I'm doing wrong? If I can even get the query results to
save to a variable I can manipulate that in VB, but I cant even get it
to do that.
 
D

David PONDA

Yes it will,
just define that code inside your form where you want to retrieve data


<[email protected]> a écrit dans le message de [email protected]...
That didnt seem to work, on the other hand it didnt throw up an error
either so who knows what it's doing with it ;). I currently have my
project configured to use the SQL query inside of Access, should I use
this or manually program it into VB? I'm not sure how access and VB are
working togeather on this, but unless it defines a recordset itself to
run, I'm not doing it. I wish I could see what it's code is after the
query runs so I could modify it, is this possible?

David said:
Hi,
Try this code in your main form module :

Private Sub mysearchtext_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[field2] = '" & Me![mysearchtext] & "'"
Me.Bookmark = rs.Bookmark
End Sub

Good morning internet community,

I am using Access 2000, and I am trying to do something that shouldnt
be as hard as it's appearing. I have data entry boxes to input data and
store into access tables. Then on a separate tab I have a subform that
I wish to display the data (view only). I have a search box for a 6
digit number, and when I click the button, I want it to do an SQL query
to select field1 from table1 where field2 = mysearchtext. Then I want
the output from that to go into the box that will be display only let's
say mysearchresultstext. I at first tried doing the SQL query in VB,
since I am more familiar with VB then I am with the Access GUI, but all
I could return was the actual SQL string instead of the processed
results. If I run a query using the GUI, it pops up a query screen with
the results, but I can not get it to a) stop showing the query results
and b) put the results into mysearchresultstext. Getting the data in is
so simple, that I know I'm putting the cart before the horse here. Any
ideas on what I'm doing wrong? If I can even get the query results to
save to a variable I can manipulate that in VB, but I cant even get it
to do that.
 
Top