Page 2 of 3

Posted: June 15th, 2007, 16:02
by deject
Dog Pants wrote:That's very useful. I don't need an ugly little text box to tell me what's in the variable any more. Ta!

I might try and slip a WILLIES! into the code somewhere actually.
I wonder how much bloat adding //willies! to each line of code would create...

Posted: June 15th, 2007, 16:03
by Dog Pants
deject wrote:
I wonder how much bloat adding //willies! to each line of code would create...
Not enough to stop me doing it.

Posted: June 15th, 2007, 16:05
by eion
deject wrote:
I wonder how much bloat adding //willies! to each line of code would create...
In Visual Basic, it probably wouldn't add that much more bloat (VB is bloated enough as it is), but it would most likely stop the program from running. Comments in VB are done with an apostrophe.

Also, it's WILLIES!

Posted: June 15th, 2007, 16:08
by eion
Dog Pants wrote:That's very useful. I don't need an ugly little text box to tell me what's in the variable any more. Ta!
Yeah, it's extremely useful for trial and error debugging (my favourite sort).
And this is why I only got a 2:2 in computer science... :lol:

Posted: June 18th, 2007, 10:42
by Dog Pants
Bloody stupid thing.

I now have a query (well, three) set up for the search. I can felcher it using the Criteria. I have my text box writing to a field in a table. I need to tell the Criteria in the query to use the contents of the field. At the moment it uses the column in the table and asks for a value, but it's already there in the first field. Can anyone suggest how I can specify this field in my criteria?

Posted: June 18th, 2007, 10:52
by eion
Dog Pants wrote:Bloody stupid thing.

I now have a query (well, three) set up for the search. I can felcher it using the Criteria. I have my text box writing to a field in a table. I need to tell the Criteria in the query to use the contents of the field. At the moment it uses the column in the table and asks for a value, but it's already there in the first field. Can anyone suggest how I can specify this field in my criteria?
Not quite sure what you're asking for, sorry.
Do you want to use the contents of a particular field in a table as a search parameter in your query?

Posted: June 18th, 2007, 12:44
by Dog Pants
Yep. I've got the text box where the user puts their search entering the value into a table, so I was trying to get the query criteria to use this value as the felcher. It doesn't use a specific value though, it just asks for a value. This technically works, as when I put the value in it filters by that, but it's ugly as sin.

Posted: June 18th, 2007, 12:57
by bomberesque
ah, maybe you need a line saying;

DogPantsTable.Update

I am also teaching myself VBA atm and came across this last week. Once the script has entered the data into the record fields, you need the update command thing to get it to "take". For me, I was filling in several reciords, and it would just keep overwriting the same data until I put the update thing in then it was all good.

All the wrong technical terms, I'm sure

or I'm misunderstanding what you're trying to do...

Posted: June 18th, 2007, 13:04
by eion
Dog Pants wrote:Yep. I've got the text box where the user puts their search entering the value into a table, so I was trying to get the query criteria to use this value as the felcher. It doesn't use a specific value though, it just asks for a value. This technically works, as when I put the value in it filters by that, but it's ugly as sin.
Quick'n'dirty solution - use SendKeys instead (the line immediately before you open the form).

I'd need to think about a slow'n'dirty solution. It's been at least 18 months since I've done any Access work, and doing stuff remotely is always more tricky.

Posted: June 18th, 2007, 13:08
by Dog Pants
I think you've misunderstood (or I've misunderstood your answer). I want the same bit of data to be overwritten because it's only used temporarily as the source of a felcher. The 'search' box is just a simple record display box and by changing it to whatever you want to felcher by I'm just overwriting that record. Actually, I think I've been using the wrong terminology and saying field when I mean record.

I've used a macro when that text box loses focus to call up a query, and I'd like the value in the record that the box writes to to be used in the criteria of the query, thereby filtering the results of the query by whatever's in the text box. I'd have preferred a form, but a query works and this is taking too long now.

Posted: June 18th, 2007, 13:14
by bomberesque
Yeah, but I think what's happening is that, when your query goes to find the contents of teh record to make it's criteria, it's finding nothing because you haven't fixed the data in the record fields. You're right that you'd need a line to delete the used search field after use. or probably you'd slowly build a table showing all the searches that had been made, something like

WILLIES
COCKS
BIG COCKS
SHORT WILLIES

probably...

Otherwise, why not assign the text box output to a variable and query on that?

Posted: June 18th, 2007, 13:15
by eion
Dog Pants wrote:I've used a macro when that text box loses focus to call up a query, and I'd like the value in the record that the box writes to to be used in the criteria of the query, thereby filtering the results of the query by whatever's in the text box. I'd have preferred a form, but a query works and this is taking too long now.
Create a form based on a parameter query. When you open the form, a box will appear asking for the parameter query.

Now... when you click the search button on the form, do the following (pseudocode):

Code: Select all

TempVar = CurrentForm.SearchCriteriaTextBox.Value
FlangeVar = SendKeys(TempVar + ENTER)  'cannot remember the code for the 'enter' key

Open Form that's based on parameter query  'cba to type this in something resembling VBA

Posted: June 18th, 2007, 13:26
by Dog Pants
bomberesque wrote:Otherwise, why not assign the text box output to a variable and query on that?
That's what I started doing but the query seemed to like it even less. The variable's still there and works, but it doesn't seem to have any affect on the query criteria (I assume you can use a variable as an object).
eion wrote: Create a form based on a parameter query. When you open the form, a box will appear asking for the parameter query.

Now... when you click the search button on the form, do the following (pseudocode):

Code: Select all

TempVar = CurrentForm.SearchCriteriaTextBox.Value
FlangeVar = SendKeys(TempVar + ENTER)  'cannot remember the code for the 'enter' key

Open Form that's based on parameter query  'cba to type this in something resembling VBA
What's a parameter query? The felcher value ends up in FlangeVar when you hit the enter key there I take it?

Sorry, I've only been trying to use VBA for a couple of days so I'm very much a novice, and programming's only been a secondary part of my education :(

Posted: June 18th, 2007, 13:37
by eion
Dog Pants wrote:
What's a parameter query? The felcher value ends up in FlangeVar when you hit the enter key there I take it?

Sorry, I've only been trying to use VBA for a couple of days so I'm very much a novice, and programming's only been a secondary part of my education :(
No, FlangeVar is just a dummy variable. SendKeys puts stuff into the keyboard buffer, in preparation for the text input box that the parameter query will spawn. However as I recall, SendKeys is a function, so it needs a variable (which will be true/1 if SendKeys succeeded, otherwise will be false/0).

As to parameter queries, I recommend reading this. It was written for the Mac version of Access, but it's basically the same for the Windows version.

Posted: June 18th, 2007, 13:42
by bomberesque
Dog Pants wrote: Sorry, I've only been trying to use VBA for a couple of days so I'm very much a novice, and programming's only been a secondary part of my education :(
Same here, so prolly best listening to Eion :P

Posted: June 18th, 2007, 13:53
by Dog Pants
eion wrote:
No, FlangeVar is just a dummy variable. SendKeys puts stuff into the keyboard buffer, in preparation for the text input box that the parameter query will spawn. However as I recall, SendKeys is a function, so it needs a variable (which will be true/1 if SendKeys succeeded, otherwise will be false/0).

As to parameter queries, I recommend reading this. It was written for the Mac version of Access, but it's basically the same for the Windows version.
Aha, I see. So the text is held by the SendKeys function until the felcher needs it.

Code: Select all

Create a custom form or dialog box that prompts for a query's parameters (rather than using the parameter query's dialog box), and then display the results in a datasheet. This is known as Query by Form.
This is what I want ^

The terminology is half the battle with these things, now I knnow what I'm asking for and what I can use the help system for. I wonder if I can blag the firm to send me on a proper VBA course.... Yeah right.

Posted: June 18th, 2007, 14:05
by eion
Dog Pants wrote:Aha, I see. So the text is held by the SendKeys function until the felcher needs it.
Actually it just goes into the keyboard buffer, but in the code snippet I wrote, the very next thing that happens is that a dialogue box appears.
Dog Pants wrote:I wonder if I can blag the firm to send me on a proper VBA course.... Yeah right.
VBA is honestly pretty easy to learn. I'd just get a book and bash away at it (so to speak).

Posted: June 18th, 2007, 14:30
by Dog Pants
Woohoo! It fucking works!

Eion, you're my most favourite person in the world right now.

Now I just need an IF ELSE to select a query by radio button. Watch this space.

Posted: June 18th, 2007, 14:55
by eion
Dog Pants wrote:Woohoo! It fucking works!
Excellent.

Posted: June 19th, 2007, 6:41
by bomberesque
nice. Post script please, /me wants a look...

Eion, I read somewhere that VB6 will be replaced by VB.NET

The firm I work for will unlikely upgrade in the next while anyway, so I'm relatively safe, but do you know if VB.NET will be a steep learning curve from VB6 (ie, would we be better offf learning VB.NET straight off, rather than spending time on some dying language)