473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

OnClick Event coding

Stang02GT
1,208 Expert 1GB
Can anyone help me out with some VBA coding.


I would like to have two text boxes where the user can enter a number in either of the boxes and click a search button to bring up the record.

Example of this is:

VIN num SEARCH
Model num

User can enter a VIN or model number depending on which one they have. ***These are not the feilds im using just examples****


I need help with the OnClick event coding
Jun 14 '07 #1
12 4066
NeoPa
32,556 Expert Mod 16PB
Please remember to provide a meaningful Title for any threads started (Please Use Appropriate Titles for New Threads!). This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.

MODERATOR.
Jun 15 '07 #2
vkong85
24
Can anyone help me out with some VBA coding.


I would like to have two text boxes where the user can enter a number in either of the boxes and click a search button to bring up the record.

Example of this is:

VIN num SEARCH
Model num

User can enter a VIN or model number depending on which one they have. ***These are not the feilds im using just examples****


I need help with the OnClick event coding

what exactly is the problem with the onclick event coding?
Jun 15 '07 #3
JKing
1,206 Expert 1GB
If I have this right you want to prompt the user for two values and then clicking the search button bring up a form displaying the record specific to those values.

Let's assume the two values we are working with are modelID and yearID and they are text data types.
The corresponding text boxes are txtModelID and txtYearID.
The form for the record will be frmDisplayRecord.

The values from the textboxes will be used to build the WHERE statement of the open form command. Once built we just pass the string in as a parameter along with the name of the form we want to open.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.  
  3. Dim strLinkCriteria As String
  4.  
  5. strLinkCriteria = "modelID = '" & Me.txtModelID & "' AND yearID = '" & Me.txtYearID & "'"
  6.  
  7. Docmd.OpenForm "frmDisplayRecord", acNormal,, strLinkCriteria
  8.  
  9. End Sub
  10.  
If the values are not text remove the single quotes.

If this is not what you're trying to do please repost your question in more detail otherwise good luck and I hope this helped.
Jun 16 '07 #4
Stang02GT
1,208 Expert 1GB
I think to simplify this situation I'd like to just focus on getting a simple search to work.

The users do not like the combo box search for whatever reasons, so the would like to see a text box ( where they may enter there criteria) and a "Search Button" to execute the search.

I'll try to explain this and not confuse you :)

I have a four tables and all data in the tables has a TC NUM (Primary Key). I have forms for each table ( based on user request, because each table relates to a different area of the company) to search/update/delete...etc.

The users would like to search by TC NUM. But they would like to have it in the form of a txt box with a "Search BUtton".

I hope this helps, and thank you for trying to help me!!!















If I have this right you want to prompt the user for two values and then clicking the search button bring up a form displaying the record specific to those values.

Let's assume the two values we are working with are modelID and yearID and they are text data types.
The corresponding text boxes are txtModelID and txtYearID.
The form for the record will be frmDisplayRecord.

The values from the textboxes will be used to build the WHERE statement of the open form command. Once built we just pass the string in as a parameter along with the name of the form we want to open.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2.  
  3. Dim strLinkCriteria As String
  4.  
  5. strLinkCriteria = "modelID = '" & Me.txtModelID & "' AND yearID = '" & Me.txtYearID & "'"
  6.  
  7. Docmd.OpenForm "frmDisplayRecord", acNormal,, strLinkCriteria
  8.  
  9. End Sub
  10.  
If the values are not text remove the single quotes.

If this is not what you're trying to do please repost your question in more detail otherwise good luck and I hope this helped.
Jun 18 '07 #5
JKing
1,206 Expert 1GB
How are you displaying search results to the user? Are you using a subform, report, seperate form or do you just want the current form to flip to that record?
Jun 18 '07 #6
Stang02GT
1,208 Expert 1GB
How are you displaying search results to the user? Are you using a subform, report, seperate form or do you just want the current form to flip to that record?


I have to current form bringing up that record. I have Text Boxes for each feild and when a search is completed the data is brought up in the respective feild.
Jun 18 '07 #7
JKing
1,206 Expert 1GB
Alright. You can try setting the form's filter property and then turning the filter on when the user clicks the search button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2. Me.Filter = "TCNUM = " & txtSearchValue
  3. Me.FilterOn = True
  4. End Sub
  5.  
TCNUM would be the key you want to search by and txtSearchValue is the textbox the user is inputting the search value into.

If the key you are searching by is a text data type then you would alter the 2nd line by enclosing the textbox value in single quotes:
Expand|Select|Wrap|Line Numbers
  1. Me.Fiilter = "TCNUM = '" & txtSearchValue & "'"
  2.  
Let me know how this works out.

JKing
Jun 18 '07 #8
Stang02GT
1,208 Expert 1GB
Alright. You can try setting the form's filter property and then turning the filter on when the user clicks the search button.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSearch_Click()
  2. Me.Filter = "TCNUM = " & txtSearchValue
  3. Me.FilterOn = True
  4. End Sub
  5.  
TCNUM would be the key you want to search by and txtSearchValue is the textbox the user is inputting the search value into.

If the key you are searching by is a text data type then you would alter the 2nd line by enclosing the textbox value in single quotes:
Expand|Select|Wrap|Line Numbers
  1. Me.Fiilter = "TCNUM = '" & txtSearchValue & "'"
  2.  
Let me know how this works out.

JKing



Unfortunatly i am getting an error message

RUN TIME ERROR '2448'

YOU CAN"T ASSIGN A VALUE TO THIS OBJECT
Jun 18 '07 #9
JKing
1,206 Expert 1GB
Are you using the textbox you display your TCNUM in to act as your search textbox as well?

Is there a space in the field name that you are passing to the Me.Filter = ?
Example: Me.Filter = "Model Number = "

In this case you need to add [] around the field
Me.Filter = "[Model Number] = "
Jun 18 '07 #10
Stang02GT
1,208 Expert 1GB
Are you using the textbox you display your TCNUM in to act as your search textbox as well?

Is there a space in the field name that you are passing to the Me.Filter = ?
Example: Me.Filter = "Model Number = "

In this case you need to add [] around the field
Me.Filter = "[Model Number] = "

No i have a seperate box in the hearder where the search button/box is
Jun 18 '07 #11
JKing
1,206 Expert 1GB
I made a quick edit there did you see the second possibility?

And if it isnot that could you paste me the snippet of your code.
Jun 18 '07 #12
Stang02GT
1,208 Expert 1GB
I made a quick edit there did you see the second possibility?

And if it isnot that could you paste me the snippet of your code.
Good news i was able to complete this task here is the code....

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command35_Click()
  2. If IsNull(Text15) = False Then
  3.         Me.Recordset.FindFirst "[TC Num]=" & Text15
  4.         End If
  5. End Sub
Jun 19 '07 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
4
by: masantha wee | last post by:
Hi all, I am using Firefox and embedding Javascript in html. I understand that we can use mouse events by coding them in the body of html (by creating a button or anything and by adding in the...
1
by: Michel Bany | last post by:
Hello everybody, I am attaching an onclick event handler to a checkbox, using a <script> tag <script>document.getElementById(id).onclick = ...</script> and I have three questions. 1) In the...
2
by: DataSmash | last post by:
Hello, I've created a simple form with 2 radio boxes, 2 text boxes and a button. When I click the button, I'd like to write each "choice" to a text file. I can't figure out how to "link" the...
11
by: GaryB | last post by:
Hi Guys, I've been battling with this one for hours - I hope that you can help me! My code modifies the <aon a page, from a standard document link into a link with a tailored onclick event. ...
9
by: monomaniac21 | last post by:
hi all i want to use hyperlinks to 'load' content by changing the display of div tags. the problem i have is that unless i specify a href the anchor does not change the mouse pointer on hover...
1
by: theS70RM | last post by:
yea i know there is millions of stuff about this on the net, and this isnt really a question but just wanted to see if people had picked up anything similar. This is only for internet explorer,...
5
by: ceejee | last post by:
hello there! i had spent lots of time searching and thinking what is the reason why in onClick event like the one below, when a certain space between words is existed, it doesnt function well. can...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.