Code Triggered From Label On Click Behaves Differently From Command Button On Click
Nov 7, 2006
Often I use Labels as buttons due to the fact I can colour them the way I want, and use the on click event to trigger code.
The code below however works for a command button, but not a label button.
DoCmd.OpenForm "frmdatetime"
Do While Forms!frmdatetime!OKFlag.Caption = "False"
DoEvents
Loop
When this code is run by clicking on a command button, it works fine.
If run by clicking on a label, frmdatetime opens, but the mouse will not work on either of the 2 open forms unless you go down to the windows task bar, jump onto another window, and back onto frmdatetime.
If I remove the loop with the DoEvents in it, then the problem does not occur.
Can anyone enlighten me as to why this behaviour occurs.
Thanks
Richard
View Replies
ADVERTISEMENT
Aug 9, 2005
Hi all!
I have this command button whose caption switches from update record to save record with a msgbox verifying if the person really wants to take this action. On click the user is then allowed to update the record then in theory they would be able to hit the same button whose caption now reads save record, the msg box would appear with a yes or no answer required. The code I have is putting the msg box after the user clicks the update button.
Anyhelp and/or suggestions would be most appreciated!
Private Sub cmdOpen3_Click()
stDocName = "frmSearch"
If cmdOpen3.Caption = "&Update Record" Then
If IsNull(Me.FTMSubform.SourceObject) = False Then
Me.FTMSubform.SourceObject = "frmFTMInfo"
Me.FTMSubform.Form!txtFirstName.Enabled = True
Me.FTMSubform.Form!txtFirstName.Locked = False
Me.FTMSubform.Form!txtFirstName.BackStyle = 1
Me.cmdOpen3.Enabled = True
Me.cmdOpen3.Caption = "&Save Record"
Me.cmdOpen4.Enabled = False
Me.cmdOpen4.Caption = "&Update Record"
Else
Me.FTMSubform.Form!txtFirstName.Enabled = False
Me.FTMSubform.Form!txtFirstName.Locked = True
Me.FTMSubform.Form!txtFirstName.BackStyle = 0
Me.cmdOpen3.Enabled = False
Me.cmdOpen3.Caption = "&Save Record"
Me.cmdOpen4.Enabled = True
Me.cmdOpen4.Caption = "&Update Record"
End If
End If
If cmdOpen3.Caption = "&Save Record" Then
If IsNull(Me.FTMSubform.SourceObject) = False Then
Me.FTMSubform.SourceObject = "frmFTMInfo"
If MsgBox("Save update to this individual?", vbQuestion + vbYesNo, "Save Update?") = vbYes Then
DoCmd.Save
DoCmd.Close acForm, "frmFTM"
DoCmd.OpenForm stDocName
Else
MsgBox "Return to the FTMInfo Form!", vbInformation, "Save Function Aborted!"
End If
End If
End If
End Sub
~Van
View 2 Replies
View Related
Oct 18, 2013
I would like to make an append query to piece together multiple tables into a holding table, once the command button is clicked.
a) how to make an append query in vba,
b) How to call an append query on click of a command button?
View 1 Replies
View Related
Jun 26, 2014
I have a command button using this code:
If Me.Setfilter.Caption = "Search By Hedging Program" Then
Me.Filter = "Hedging Program"
Me.FilterOn = True
cmd.Setfilter.Caption = "Don't Search By Hedge Program"
Else
Me.FilterOn = False
cmd.Setfilter.Caption = "Search By Hedging Program"
End If
Hedging program is the column from the table I am trying to filter, it is a yes/no column. I want it to return all yes values in my query if it says search by hedging program and if it says Don't search by hedging program I want it to disregard the filter. I also have it set so that when I click the button it changes the caption from one to the other. So I don't know if I really need the cmd.setfilter lines because they may do the same as my command button on click function.
View 14 Replies
View Related
Apr 14, 2012
I have a command button on a Web Mutli-Record form that is using a "= [Report_URL]" value within the Hyperlink Address property. This all seems to work other than the fact that when the link popups up it has a "#" on either side that basically makes it an invalid address. How do I get rid of the # signs to get the web address popup in the URL when a user clicks on the Command Button that is associated to the row the record is on.
View 4 Replies
View Related
May 27, 2014
In the Main Form , I have few buttons and I am writing the following code to open the right form when a button is clicked but unfortunately the code isn't doing anything. No form is opening. I am using MS office 2010.
Code:
Private Sub BtnOption_Click()
DoCmd.OpenForm "Form1", acNormal, , , acFormAdd, acDialog
End Sub
Private Sub Form_Load()
'Me!Label1.Caption = "Welcome " & Environ("username") & "!"
[code]....
View 14 Replies
View Related
Nov 12, 2014
I need to return a folders directory to a text box on my forms record called Files_Directory when i click the Browse command button... The folder will have more folders within it along with documents all relivant to the folder selected, hense the need for just the folder directory rather than a file.
View 12 Replies
View Related
Sep 28, 2014
i have a label and a combobox (the combobox is invisibile). in a form.
how do i make the combobox visibile when i click on the label?
View 2 Replies
View Related
Jan 24, 2006
Dont be overwhelmed by the following, but it may require some extensive thought and I dont expect everyone to understand....
I want to have a unbound form control a subform. On the form I have an unbound text area entitled txtDate. In this area it displays the current date being viewed. I have put left and right buttons on the main form that will add (+1) one day to the date being shown and subtract (-1) one day from the date being shown. I want to conrol it though the "On Click" but I dont know what to enter in the "On Click" field that will allow me this. The reason is, co-insiding with the previous, when the date is changed, the subform is also changed to a new day. Therefore instead of displaying 24 hours of today, you can view 24 hours of yesterday, tomorrow and so on. See, if one is to set the onclick to be: Me.txtDate=Me.txtDate-1, or Me.txtDate=Me.txtDate+1, it calls for a custom macro and I dont know why. I know it somehow resides in some similar command set up.
I also need to know how to make the subform bound but continous, and what exactly does that mean?
Anyone care to offer some assistance? :confused:
View 4 Replies
View Related
Jun 27, 2005
Hi everyone!
First, I want to say I would REALLY appreciate any help I could get with this problem. Let me lay out the details.
I DO NOT, DO NOT, DO NOT know the first thing about programming for ms access. I am an absolute novice, no exaggeration at all. I was a liberal arts major in school!!!!!
Here's the thing: being adventurous and all, about 2 years ago a co-worker and I were fiddling with databases to try and help out our employer keep track of dispatching his equipment for his business. With a little too much time on our hands, before we knew it, our database became fairly complicated, for such novices. A kind gentleman on this forum did us an enormous favor, and programmed a search form for our database. you could enter any or all of the id #'s for various equipment, and it would pop up in a list box. Double-clicking the listbox would open the particular record you were looking for.
Fast-forwarding to now, I'm trying to create another database to keep track of our inventory while while various equipment moves in and out of our yard. I have tried using the old search form as a foundation to create a similar search form for this db. I think I actually have it (kind-of) working! You type in a container number, and the record should pop up. which is a miracle all its own.
problem is, is that when you doubleclick the selection in the list box, I receive the following error:
"Run-time error '3075':
Syntax error (missing operator) in query expression '[ShipID] = '.
I click debug, and visual basic brings me to:
DoCmd.OpenForm "Inventory Table Form",,, "[ShipID] = " & Me.lstInfo
I don't know what to do! I'm sure it must be something painfully simple or obvious, but I'm really stuck & would appreciate any help.
Also, I would really appreciate any advice on this: I'd like to also be able to search by chassis # in addition to container number, but i don't know how to do it. no big deal, though. THANKS SO MUCH!!
p.s., I've attached the db. please let me know if you can open it ok
View 1 Replies
View Related
Nov 4, 2004
I'm new in access world. please help. I have many forms that control by On click command from the main form. One of the form (which is Calendar form), I like to have password protect in away that only the right ID or password would have access to edit this Calendar, If not users can only view it. Is this possible?, if it is can you please provide some code for me...Thanks in advance..
View 1 Replies
View Related
Aug 13, 2014
I have a form that i used the following code on to stop people accessing anything naughty:
Code:
Dim i As Integer
For i = 1 To CommandBars.Count
CommandBars(i).Enabled = False
Next i
This works great and gets rid of all the menu bars.
The problem is that it also stops the user getting the right click menu up in a datasheet view.
I assume i just need to enable the correct menu bar index number but i don't know what it is so my code would be:
Code:
CommandBars(X).Enabled = True
So do I need to bring back more than one command bar to get it working?
View 4 Replies
View Related
Feb 17, 2014
Code:
Private Sub Check237_Click()
If Me.Check237.Value = "yes" Then
Me.Text239.Visible = True
Else
Me.Text239.Visible = fasle
End If
End Sub
I am using the code above and what the desired action is when the Check237 is checked then the Text239 is visible for the user to put in a comment. However, as of now when the check237 is checked the textbox dissapears.
View 3 Replies
View Related
Sep 20, 2006
Ok if I sound like I do not know what I am talking about, that would be correct. That is why I am asking here.
So I have this form called frm_UserMaintenance
On The form I have a button
I would like to have an OnClick event that will activate one of the dialogue boxes on the tools menu.
Heres the catch. The menu is not visible and i do not want to make it visible. This makes using sendkeys a non option.
Any ideas????
View 5 Replies
View Related
Sep 13, 2005
Private Sub tbxPoor_DblClick(Cancel As Integer)
Me.TtbxPoor= Me.TtbxPoor+ 1
End Sub
This simple event on double clicking a field on my form increments the number in the field by 1. There are 10 fields in all where I want the user to be able to do the same. Is there an elegant way to code this event for all those fields using one routine or is it best to add the event to each field?
View 10 Replies
View Related
Dec 14, 2006
Hello..
I have the following code that I have been trying to get to work:
Private Sub txtSocNumber_DblClick(Cancel As Integer)
On Error GoTo Err_txtSocNumber_DblClick
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FrmApplicantFullDetails"
If IsNull(Me.txtSocNumber) Or Me.txtSocNumber = "" Then
MsgBox "This record is empty", vbInformation, "No Data"
Me.txtSocNumber.SetFocus
Else
stLinkCriteria = "[ApplicantID]=" & Me![InvestigatorID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
Exit_txtSocNumber_DblClick:
Exit Sub
Err_txtSocNumber_DblClick:
MsgBox Err.Description
Resume Exit_txtSocNumber_DblClick
End Sub
I have the following two tables:
Applicant and Investigator
Applicant:
ApplicantID
InvestigatorID
etc
Investigator:
InvestigatorID
etc
The relationship is setup as 1 investigator to many applicants.
What I am trying do is this. I have form with a subform in it. In the subform there is applicant info IE SS# LName, FName and that is it. What I want to do is be able to double click on the SS# have the form "FrmApplicantFullDetails" open so you can view the work up on the applicant or edit info on the applicant.
Am I going about this the right way with the above code? Or is there something else I am missing in the code or is there code out that will do what I am looking for that is easier?
Thanks
R~
View 5 Replies
View Related
Aug 12, 2005
Hi, I have got a small problem and maybe someone could advise me.
I am creating a customised command button from a label button. The new button works fine but I can't apply the 'requery' function to it, if i do an error occures and i am being prompt to save the data first???? :confused: :
Private Sub Labelsearch_Click()
Me!itemquery.Requery
End Sub
Private Sub Labelsearch_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Labelsearch.SpecialEffect = 2
Me.Labelsearch.BackColor = 255
Me.Labelsearch.ForeColor = 10092543
Me.Labelsearch.FontItalic = True
Me.Labelsearch.FontBold = True
End Sub
Private Sub Labelsearch_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Labelsearch.ForeColor = 255
Me.Labelsearch.FontItalic = False
Me.Labelsearch.FontBold = True
End Sub
Private Sub Labelsearch_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Come back to initial state when button release'
Me.Labelsearch.SpecialEffect = 1
Me.Labelsearch.BackColor = 16373685
Me.Labelsearch.ForeColor = 8388608
Me.Labelsearch.FontItalic = False
Me.Labelsearch.FontBold = True
End
If I create a command button with the wizard and assign the code :
me!itemquery.Requeryto the on_click event my form is working fine.
Why is his code is not working if I assign it to a label? :o
View 6 Replies
View Related
May 26, 2015
I'm currently trying to make the call answering screens a bit better in the call centre that i work in. i'm trying to make a caller i.d. for incoming calls. i have a reference library from the telephone software people in vba that lets me dial and hangup the phone, now i'm trying to place a text box on the form that will update to show the number of an incoming call which will enable me to search a table of contacts and display the details of the caller if they are available. i'm guessing that i need to create a loop that will run until there is an incoming call but i don't know where to place the code without it needing a mouse click or mouse over to trigger it. i just want it to run constantly.
View 5 Replies
View Related
Feb 9, 2005
I have a form on which I have a button that I want the user to click after a cetrain field on that form is updated.
I display a little pop-up box saying to make sure that a user clicks on that button.
Is there a way to know that this button was clicked? Is there a way to not proceed with anything else until that button is actually clicked?
Thanks.
View 4 Replies
View Related
Sep 19, 2005
Hi,
I have a form with a number of drop-down lists on it and each of these lists is bound to a field in a table.
When I return the results of a search to this form I want to allow users to be able to cycle through the records and change them if they want. However, the changes should only be saved if the user clicks on the "update record button". This button is simply the save record button by the MS Access wizard.
At the moment if they change the value in one of the drop down lists and move onto the next record the change is saved even though the user doesn't click any button. I want to prevent this from happening.
Any ideas on how I might achieve this?
If I prevent "AllowEdits" in the form properties I can't update the form using the "update record button" either.
Many Thanks,
View 2 Replies
View Related
Nov 10, 2005
Afternoon people,
Just a query (no pun intended). Is there a way to ping an ip address which is taken from a table and at the click of a button it pings? Bringing up the cmd app to show the results.
Cheers,
Storm1976
View 1 Replies
View Related
Nov 22, 2005
I currently have a form with a button that once clicked displays a word document,however I have to double click on the button even though the code is on the single click event property.The only line of code is as follows
OLEFile.Action = acOLEActivate
Does any body know how I can get the single click to work ?
View 2 Replies
View Related
Sep 6, 2006
Hi all....
I have a list box that I can select mulitple items from - I then click a search button and it runs a query that finds what I am looking for from a table and then displays the results in a subform.
In the subform I can input weights and get a percent....anyhow.
How do I set up a button so that it will print out a report or the report from the subform information that is currently being viewed.
Also, I can already do this by clicking a button on the form and pulling up the installed report program but, you need to input data to get this report.
I kinda want this button to be a "I need it now" type of print option.
Thanks...as always my questions are probably confusing...:D
View 2 Replies
View Related
Sep 7, 2006
I was wondering if there is any way to control a user's input in to a form such that data entry does not automatically create a new record. Is there any way to collect all inputs in the text/combo boxes and create the new record only when a button is clicked? Cheers, David.
View 1 Replies
View Related
Oct 26, 2005
Adding Records Only On Button Click?
I am building a database with a single table of records. I have created a form to allow new entries to be made to the table in a user-friendly way.
The problem I’m stuck with is how do I restrict the addition of new records on the form? I want the new record to only be added to the table upon the click of a button, but at present if I tab through, or exit the form the record is saved anyway.
Not all fields on the form are required input so I’m thinking that validation of every field is not the way to go.
I only ever want the record to be saved if a user clicks on a button and under no other circumstance.
I've been trawling through the posts back to about page 15 so any help would be appreciated.
Ksan
View 4 Replies
View Related
Feb 6, 2006
Hello everyone!I need to call the button_click procedure for a button on a form (button1), from another form, if you see what I mean!.Basically the user opens form1. They click a button which opens form2. Once they have finished on form2 they press the close button, which is the point where I need to call the button1_click procedure on form1.I imagine it's something like this:Call Forms![frmForm1]![button1]![Click] orCall Forms.[frmForm1].[button1_Click()]But no matter what syntax I try it just won't work! They're very basic forms, with only 2 buttons on and basic commands.Any help appreciated! Thanks
View 5 Replies
View Related