A Weird Bug In My Tables

xMax

Registered User.
Local time
Yesterday, 20:29
Joined
Aug 7, 2006
Messages
35
I am conducting a search for certain records in a table using a select query and a form. However, when I do the search, one of the rows in the table gets modified do whatever it is I am looking for, and of course, I don't want that to happen.

Query Code:

SELECT *
FROM Games
WHERE Game=Forms.frmSearchByGame.txtGame;


Sample of the Table (Before Search):

ID Game Date Beaten Beaten By

1 Zelda 8/09/08 Me
2 FFXII 10/23/08 Fred
3 DOOM 6/09/94 Me

Suppose I do a search for DOOOM. It won't find anything but this is what the table looks like:

Sample of the Table (After Search):


ID Game Date Beaten Beaten By

1 DOOOM 8/09/08 Me
2 FFXII 10/23/08 Fred
3 DOOM 6/09/94 Me

Any Ideas Here???
 
Last edited:
My first guess would be that your form is "bound" to the query, so that when you update your "search criteria", you are actually updating the table.
 
Ok, I unbounded the form and textbox, but now it asks for the Parameter Game after I hit the search button.
 
I assume you're running some VBA behind your button? Looks like you may have a problem in the SQL you are trying to execute. Let's have a look at that.
 
Hi,

If you have unbounded the textbox, all you have to do is simply put [Forms]![FormName]![TextboxName] in the criteria row in your query under the Game field.
 
SELECT *
FROM Games
WHERE Name=Forms!frmSearchByName!txtName;
 
I solved it; I am such an idiot. The fields in the table did not match the fields I was looking for.
 
(A=Forms.frmMasterSearch.txtA
Or A=Forms.frmMasterSearch.txtA2
Or A=Forms.frmMasterSearch.txtA3
Or A=Forms.frmMasterSearch.txtA4
Or A=Forms.frmMasterSearch.txtA5) And B=Forms.frmMasterSearch.txtB
And C=Forms.frmMasterSearch.txtC
And D=Forms.frmMasterSearch.txtD

I want the query to look up every field that has data in it. In this case, fields B through D have one text box where you can enter data, while field A has five text boxes (you can enter up to 5 fields.

So let's say I enter Demon and Baron Of Hell for field A, DOOM for field B, Zombieman for field C, and Tenements for field D. What I want is a query that returns every field that has either Demon or Baron of Hell for field A, Doom for field B, Zombieman for field C, and Tenements for field D. Can anyone please tell me what I am doing incorrectly?
 
That query is going to require input into EVERY text box. If you leave one blank, it's going to look for corresponding fields that contain Null.

If you're looking for exact matches, I think you'll have to build the string with VBA, and then put it in your querydef. If you can use LIKE, you can still get away with it in a query. In that case, if the user puts DOOM in txtB, he'd see any record with the word DOOM somewhere in field B. What's your preference?
 
I need a query, but I cannot use the like statement.
 
Last edited:
If you use a combo box for the user input they will only be able to choose exact data as a parameter. The LIKE operator will not be able to produce near matches but you will still be able to use the wild card.
 

Users who are viewing this thread

Back
Top Bottom