Anyone know how to drive Access?

If you touch your software enough does it become hardware?

Moderator: Forum Moderators

deject
Berk
Berk
Posts: 10353
Joined: December 7th, 2004, 17:02
Location: Oklahoma City, OK, USA
Contact:

Post 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...
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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.
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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!
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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:
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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?
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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?
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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.
bomberesque
Optimus Prime
Optimus Prime
Posts: 1100
Joined: November 26th, 2004, 22:23
Location: Belgium
Contact:

Post 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...
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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.
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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.
bomberesque
Optimus Prime
Optimus Prime
Posts: 1100
Joined: November 26th, 2004, 22:23
Location: Belgium
Contact:

Post 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?
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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 :(
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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.
bomberesque
Optimus Prime
Optimus Prime
Posts: 1100
Joined: November 26th, 2004, 22:23
Location: Belgium
Contact:

Post 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
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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.
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post 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).
Dog Pants
Site Moderator
Site Moderator
Posts: 21653
Joined: April 29th, 2005, 13:39
Location: Surrey, UK
Contact:

Post 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.
eion
Grammar Nazi
Grammar Nazi
Posts: 1511
Joined: March 18th, 2006, 22:23
Location: Beijing
Contact:

Post by eion »

Dog Pants wrote:Woohoo! It fucking works!
Excellent.
bomberesque
Optimus Prime
Optimus Prime
Posts: 1100
Joined: November 26th, 2004, 22:23
Location: Belgium
Contact:

Post 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)
Post Reply