Query in VB will not work..What am I doing wrong?

  • Thread starter chris23892 via AccessMonster.com
  • Start date
C

chris23892 via AccessMonster.com

oh, the data type...

I have a mix of letters and numbers, no special charaters. Would be a general
format, nothing special.
That is the full SQL code that VB genorated.

I used the ~add Query~ from the datagrid control. when I go into my dataset.
xsd tab then right click on my querry (which is named now ~fill(2),getdataby
(2) then goto ~configure~, I just copied the SQL text right to here:

SELECT [Claim# 1], [Claim# 2], Comments, [DTAC Case], [Date Entered to
FPRT], [Date Receive], Dealer, [Dealer Acct #], [Entered to FPRT (Y/N)],
[Geographical Location (Ship From)], ID, [Part #],
[Product Name], [S/N], [UPS Tracking#]
FROM Check_In
WHERE ([S/N] =' Form1.me.TextBox1_TextChanged_1')

When i run my app in debug, first thing i notice is all my data does indeed
show in in my datagrid. when I scan the number into my text box and click, no
record comes up. The record is there. I can modify my filter criteria to pull
it up.
Please post the complete SQL of your query, and indicate the datatype of the
field you're searching. It's especially important to note Lookup Fields since
they don't contain what they appear to contain!
 
J

John W. Vinson

On Thu, 12 Feb 2009 17:35:01 GMT, "chris23892 via AccessMonster.com"

I'm sorry, but you're evidently (literally) speaking a different language.
This does not appear to be Access VBA at all. The syntax

Form1.me.Textbox1_TextChanged_1

is meaningless to me, and I have no idea of what the referent might be.

As written the SQL will search for records in the table CheckIn where the
[S/N] field contains that literal text string. I doubt that you have any S/N
values containing Form1.me.Textbox1_TextChanged_1!

If that is a reference to a datagrid or some other type of control, you will
probably need to extract the *value* in the textbox and append that value into
the SQL string, delimited by quotemarks, rather than the *name* of the
control; the Access query engine will have no way to ascertain what Form1.me
etc. is or what it contains.

oh, the data type...

I have a mix of letters and numbers, no special charaters. Would be a general
format, nothing special.

If it contains letters... it's a Text field in Access. The format is
irrelevant.
 
C

chris23892 via AccessMonster.com

Sorry, John. If I knew what I were doing, I'm probably not be asking for help.
I could have sworn that what these boards were for.

I was trying
Form1.me.Textbox1_TextChanged_1

To try to point my qury to the value of my box. Trying anything at this point

I am not even in access. I got this to work great in access months ago. I am
using Visual Studio 2008 now and want to build an app to do the same thing.


Ok..Crystal clear:
1.) Yes, I am in visual studio
2.) How do I tell my query to take what is in my text box and filter by it?


I'm sorry, but you're evidently (literally) speaking a different language.
This does not appear to be Access VBA at all. The syntax

Form1.me.Textbox1_TextChanged_1

is meaningless to me, and I have no idea of what the referent might be.

As written the SQL will search for records in the table CheckIn where the
[S/N] field contains that literal text string. I doubt that you have any S/N
values containing Form1.me.Textbox1_TextChanged_1!

If that is a reference to a datagrid or some other type of control, you will
probably need to extract the *value* in the textbox and append that value into
the SQL string, delimited by quotemarks, rather than the *name* of the
control; the Access query engine will have no way to ascertain what Form1.me
etc. is or what it contains.
oh, the data type...

I have a mix of letters and numbers, no special charaters. Would be a general
format, nothing special.

If it contains letters... it's a Text field in Access. The format is
irrelevant.
 
J

John W. Vinson

Sorry, John. If I knew what I were doing, I'm probably not be asking for help.
I could have sworn that what these boards were for.

I was trying
Form1.me.Textbox1_TextChanged_1

To try to point my qury to the value of my box. Trying anything at this point

I am not even in access. I got this to work great in access months ago. I am
using Visual Studio 2008 now and want to build an app to do the same thing.

Then you will need to use a different language, different conventions, and
different techniques - and I'm afraid I can't be much help, because it's a
language, convention, and techniques with which I am not familiar!
Ok..Crystal clear:
1.) Yes, I am in visual studio
2.) How do I tell my query to take what is in my text box and filter by it?

If you can figure out how to extract the *value in*
Form1.me.Textbox1_TextChanged_1 - and, as I say, not being expert in Visual
Studio 2008 I don't know how you would do so! - then you should be able to
construct a SQL string by concatenating that *value* into the SQL string. The
string you'll want to end up with will look something like the following,
assuming that the value in the textbox is AA1234:

SELECT [Claim# 1], [Claim# 2], Comments, [DTAC Case], [Date Entered to
FPRT], [Date Receive], Dealer, [Dealer Acct #], [Entered to FPRT (Y/N)],
[Geographical Location (Ship From)], ID, [Part #],
[Product Name], [S/N], [UPS Tracking#]
FROM Check_In
WHERE ([S/N] =' AA1234')


You will need the quotes around the search argument, since it's a Text field.

You might want to find a Visual Studio support forum since that's the language
environment you're using. For this particular "interface" question, it would
probably be acceptable to crosspost to the VS forum and this forum.
 
D

Dirk Goldgar

chris23892 via AccessMonster.com said:
Sorry, John. If I knew what I were doing, I'm probably not be asking for
help.
I could have sworn that what these boards were for.

I was trying
Form1.me.Textbox1_TextChanged_1

To try to point my qury to the value of my box. Trying anything at this
point

I am not even in access. I got this to work great in access months ago. I
am
using Visual Studio 2008 now and want to build an app to do the same
thing.


Ok..Crystal clear:
1.) Yes, I am in visual studio
2.) How do I tell my query to take what is in my text box and filter by
it?


I've been playing around with VS2008 and VB.Net, and now I can answer your
questions.

If you haven't already done so, create a TableAdapter and a DataSet. Add
your query to the table adapter, leaving a parameter, identified by a
question mark, in the WHERE condition, so that the WHERE clause now looks
like this:

WHERE ([Check_in].[S/N]=?)

If you test that query using the Preview Data option, you should see that
you are prompted for a parameter, and when you fill it in and click the
Preview button, the preview data grid (not the one you've designed) fills in
with the matching records.

Save those changes. Now you need to set up an event of the your text box to
fill the data grid with the results of that query, supplying the value of
the text box to the query. Suppose you use the KeyPress event for this,
only running the query when the user presses the Enter key. Your code might
look something like this:

'----- start of example code -----
Private Sub txtYourTextbox_KeyPress( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtYourTextbox.KeyPress

If e.KeyChar = Chr(13) Then

Try
Me.Check_InTableAdapter.qryFillGrid( _
Me.TestDataSet.Check_In, _
CType(Me.txtYourTextbox.Text, String))

Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

End If

End Sub
'----- end of example code -----

In the above, "txtYourTextbox" is the name of your text box,
"Check_InTableAdapter" is the name of the table adapter, "qryFillGrid" is
the name of the query, "TestDataSet" is the name of the dataset, and
"Check_In" is the name of the Data Table in the dataset.

That works for me. I'm not reallty conversant with the ins and outs of
VB.Net for Windows Forms, so there may be better or easier ways to do it.
 
C

chris23892 via AccessMonster.com

Hummmm....The query part does not seem to work.....

Changed the SQL and tried it and it pulls up a numm when prompted and I put a
known S/N in it...

SELECT ID, [Product Name], [S/N], [Part #], [Date Receive], [UPS
Tracking#], [DTAC Case], [Dealer Acct #], Dealer, [Claim# 1], [Claim# 2],
[Entered to FPRT (Y/N)],
Comments, [Date Entered to FPRT], [Geographical
Location (Ship From)]
FROM Check_In
WHERE ([S/N] = ?)

Still not sure how you are getting the contents into the query. I'll do some
playing :)

Thanks for all your help:)

Dirk said:
Sorry, John. If I knew what I were doing, I'm probably not be asking for
help.
[quoted text clipped - 15 lines]
2.) How do I tell my query to take what is in my text box and filter by
it?

I've been playing around with VS2008 and VB.Net, and now I can answer your
questions.

If you haven't already done so, create a TableAdapter and a DataSet. Add
your query to the table adapter, leaving a parameter, identified by a
question mark, in the WHERE condition, so that the WHERE clause now looks
like this:

WHERE ([Check_in].[S/N]=?)

If you test that query using the Preview Data option, you should see that
you are prompted for a parameter, and when you fill it in and click the
Preview button, the preview data grid (not the one you've designed) fills in
with the matching records.

Save those changes. Now you need to set up an event of the your text box to
fill the data grid with the results of that query, supplying the value of
the text box to the query. Suppose you use the KeyPress event for this,
only running the query when the user presses the Enter key. Your code might
look something like this:

'----- start of example code -----
Private Sub txtYourTextbox_KeyPress( _
ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles txtYourTextbox.KeyPress

If e.KeyChar = Chr(13) Then

Try
Me.Check_InTableAdapter.qryFillGrid( _
Me.TestDataSet.Check_In, _
CType(Me.txtYourTextbox.Text, String))

Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

End If

End Sub
'----- end of example code -----

In the above, "txtYourTextbox" is the name of your text box,
"Check_InTableAdapter" is the name of the table adapter, "qryFillGrid" is
the name of the query, "TestDataSet" is the name of the dataset, and
"Check_In" is the name of the Data Table in the dataset.

That works for me. I'm not reallty conversant with the ins and outs of
VB.Net for Windows Forms, so there may be better or easier ways to do it.
 
C

chris23892 via AccessMonster.com

blaaaaa....Can't seem to get it to work...going to take a break for tonight.


Gotta be close now...

If any one is REALLY interested, my email addy is:
studiobartgallery AT yahoo dot com

This may go alot better if I could email some screen shots of what I have.
Especially if you already got this to work, should work here too.

Hummmm....The query part does not seem to work.....

Changed the SQL and tried it and it pulls up a numm when prompted and I put a
known S/N in it...

SELECT ID, [Product Name], [S/N], [Part #], [Date Receive], [UPS
Tracking#], [DTAC Case], [Dealer Acct #], Dealer, [Claim# 1], [Claim# 2],
[Entered to FPRT (Y/N)],
Comments, [Date Entered to FPRT], [Geographical
Location (Ship From)]
FROM Check_In
WHERE ([S/N] = ?)

Still not sure how you are getting the contents into the query. I'll do some
playing :)

Thanks for all your help:)
[quoted text clipped - 52 lines]
That works for me. I'm not reallty conversant with the ins and outs of
VB.Net for Windows Forms, so there may be better or easier ways to do it.
 
D

Dirk Goldgar

chris23892 via AccessMonster.com said:
Hummmm....The query part does not seem to work.....

Changed the SQL and tried it and it pulls up a numm when prompted and I
put a
known S/N in it...

I'm not sure what that sentence means.
SELECT ID, [Product Name], [S/N], [Part #], [Date Receive], [UPS
Tracking#], [DTAC Case], [Dealer Acct #], Dealer, [Claim# 1], [Claim# 2],
[Entered to FPRT (Y/N)],
Comments, [Date Entered to FPRT], [Geographical
Location (Ship From)]
FROM Check_In
WHERE ([S/N] = ?)

That looks okay to me.
Still not sure how you are getting the contents into the query.

The event-handling code for the text box is supplying the value to the query
parameter when it calls the query to fill the grid. If you don't have them
wired up the way I did, you may have to tinker with it. Unfortunately for
you, I'm not an expert in .Net stuff, so I'd have a hard time figuring out
exactly what you might have to change. I suggest you take your questions
over to one of the VB.Net newsgroups that Microsoft supports. Your question
was never really an Access question, after all. Maybe you can get some
expert opinions here:

http://www.microsoft.com/communitie...?dg=microsoft.public.dotnet.languages.vb.data

I'll do some playing :)

Good luck! As I said, it works for me, with just a little time to figure
out how Visual Studio wants to do things.
 
C

chris23892 via AccessMonster.com

Posted in the forum you suggested. Thank you so much for your help.

Dirk said:
Hummmm....The query part does not seem to work.....

Changed the SQL and tried it and it pulls up a numm when prompted and I
put a
known S/N in it...

I'm not sure what that sentence means.
SELECT ID, [Product Name], [S/N], [Part #], [Date Receive], [UPS
Tracking#], [DTAC Case], [Dealer Acct #], Dealer, [Claim# 1], [Claim# 2],
[quoted text clipped - 3 lines]
FROM Check_In
WHERE ([S/N] = ?)

That looks okay to me.
Still not sure how you are getting the contents into the query.

The event-handling code for the text box is supplying the value to the query
parameter when it calls the query to fill the grid. If you don't have them
wired up the way I did, you may have to tinker with it. Unfortunately for
you, I'm not an expert in .Net stuff, so I'd have a hard time figuring out
exactly what you might have to change. I suggest you take your questions
over to one of the VB.Net newsgroups that Microsoft supports. Your question
was never really an Access question, after all. Maybe you can get some
expert opinions here:

http://www.microsoft.com/communitie...?dg=microsoft.public.dotnet.languages.vb.data
I'll do some playing :)

Good luck! As I said, it works for me, with just a little time to figure
out how Visual Studio wants to do things.
 
D

David W. Fenton

You might want to find a Visual Studio support forum since that's
the language environment you're using. For this particular
"interface" question, it would probably be acceptable to crosspost
to the VS forum and this forum.

I see no purpose in crossposting. This is not by any stretch of the
imagination an Access problem, or even a Jet problem.
 
C

chris23892 via AccessMonster.com

Again, thank you for the help :)
I've been playing with just the query, seems I'm doing something wrong there.
I got this far:


If you haven't already done so, create a TableAdapter and a DataSet. Add
your query to the table adapter, leaving a parameter, identified by a
question mark, in the WHERE condition, so that the WHERE clause now looks
like this:

WHERE ([Check_in].[S/N]=?)

If you test that query using the Preview Data option, you should see that
you are prompted for a parameter, and when you fill it in and click the
Preview button, the preview data grid (not the one you've designed) fills in
with the matching records.


When I'm prompted for my paramenter, when I enter the S/N, I still get
nothing in my data preview.

I'll keep trying :)

Would be very help ful if you could tell me some of the proporties you have
set. I think I just need to set something right for this to work.



Posted in the forum you suggested. Thank you so much for your help.
[quoted text clipped - 29 lines]
Good luck! As I said, it works for me, with just a little time to figure
out how Visual Studio wants to do things.
 
C

chris23892 via AccessMonster.com

Hold the phone!!!! Seems a technician did a swap on my test unit I've been
scanning in. That S/N was not in my teable. When I found one that was, this
worked PERFECT!!!!

Dude, I own you big time. thank you
SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO much. works like a charm
and then some. Brilliant!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Again, thank you for the help :)
I've been playing with just the query, seems I'm doing something wrong there.
I got this far:

If you haven't already done so, create a TableAdapter and a DataSet. Add
your query to the table adapter, leaving a parameter, identified by a
question mark, in the WHERE condition, so that the WHERE clause now looks
like this:

WHERE ([Check_in].[S/N]=?)

If you test that query using the Preview Data option, you should see that
you are prompted for a parameter, and when you fill it in and click the
Preview button, the preview data grid (not the one you've designed) fills in
with the matching records.

When I'm prompted for my paramenter, when I enter the S/N, I still get
nothing in my data preview.

I'll keep trying :)

Would be very help ful if you could tell me some of the proporties you have
set. I think I just need to set something right for this to work.
Posted in the forum you suggested. Thank you so much for your help.
[quoted text clipped - 3 lines]
 
D

Dirk Goldgar

chris23892 via AccessMonster.com said:
Hold the phone!!!! Seems a technician did a swap on my test unit I've been
scanning in. That S/N was not in my teable. When I found one that was,
this
worked PERFECT!!!!

Dude, I own you big time. thank you
SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO much. works like a
charm
and then some.
Brilliant!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


LOL. Let's not get carried away. You're welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top