Modules & VBA :: Click Event To Open A Form And Select Record Corresponding To Value In Unbound Text Box
Oct 29, 2013
I have some code for a button on click event to open a form and select the record which corresponds to a value in an unbound text box. The code is:
Private Sub Command25_Click()
On Error GoTo Err_Command25_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmOpenPatientRecord"
[Code] ....
This works fine when I put in a 10 digit NHS number but opens a blank record when I enter a four digit or six character/digit PatientNumber. Both patient number and NHS number are text fields in the underlying table.
View Replies
ADVERTISEMENT
Aug 11, 2014
I want to handle the event when I right click and choose "Paste" to pop up a message to the user that he cannot paste; disabling the pasting functionality.
I understand that the Button parameter refers to right or left button , but on which event to best use (mouse up ,mouse down , mouse move - as it seems to be a mixture of the three) and the code for that event.
Code:
Private Sub List_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' See if the right mouse button was clicked
If Button = acRightButton Then
'DoCmd.CancelEvent
'do event here
End If
End Sub
I don't want to cancel after there is a right click , but rather after right clicking and choosing "Paste".
View 9 Replies
View Related
May 8, 2014
I am new to access and I recently encountered a double click issue
My form loads perfectly on double click event but it shows the first record instead of selected record.
My search is based on a PersonID but each PersonID has different WorkID that I wish to display on double click but it always shows the first WorkID instead of my selected record
I have tried changing the filters in the form properties but it still doesn't work for me.
Here's my code:
Private Sub SearchResults_DblClick(Cancel As Integer)
DoCmd.OpenForm "WorkForm", , , "[PersonID]=" & Me.[Searchresults], , acNormal
End Sub
[Searchresults] draws information from my Query
Query information:
PersonID... WorkID... Type......Location
1234..........1............Paint .....Address A
1234..........2............Electric...Address B
1234..........3............Floor..... Address C
View 7 Replies
View Related
Aug 16, 2014
I am trying to make use of the OpenForm command to open a form to a record where a textbox matches the value of a text box on another form.
On Form1, I have a textbox called txtRtnRef, and it contains a reference number in a similar format to SWR-9
On Form2, I have a textbox called txtReOrderRef (control source ReOrderRef) which also contains a reference number in the same format (SWR-9)
I am trying to have a button next to the text box on Form1 that has an OnClick Event that opens Form2 to the record containing the same text reference number.I have tried, to no avail, a number of variations of the OpenForm command, the most recent being
Code:
DoCmd.OpenForm "Form2", , , "ReOrderRef = '" & Me.txtRtnRef & "'"
The form opens, but to a blank record?
View 6 Replies
View Related
Feb 4, 2005
Some of the things that bring me screeching halt really surprise me. I swear, this sounds like it should be so easy....
What I need to do is check, when the user clicks on a button, whether a specific table that is going to be modified/deleted later in the click code is already open. If it is open, I will msgbox the user to close the table first and exit the sub.
Any ideas?
All help, as always, is much appreciated!
John
View 4 Replies
View Related
Jul 11, 2006
I have a few search forms that, when search parameters are entered, a continuous subform displays the results (summarised...not all fields show).
I want to be able to double click a field in any given record, and have it open in a form allowing editing of the record.
I know I need something in the OnDoubleClick event of the text box I want to double click, which would then open the form, but I don't know what code to use.
For the sake of argument, I want to double click on the txtSerialNumber text box to do it, as this is a unique field.
Thanks.
View 7 Replies
View Related
Aug 9, 2014
I have a form which displays the records from a query (i have included a picture of this form) and allows me to filter them and create a report from the filter.
I'd like to be able to select a record with the record selectors (or preferably without) - and then go onto edit it in a new window and save the edit...
If possible also to select a record with or without record selectors and click a button to delete the record
searchdb.jpg
View 1 Replies
View Related
Dec 17, 2014
My form used to work and as I kept adding event scripts now when I click on the ID text field, it doesn't open the linked record, but a blank record with 'Filtered' showing on the bottom navigation. I guess a question I have is,
-is there an order on which the procedure scripts run
-do they all run everytime, or just the specific event script
===================================
Private Sub Company_Click()
DoCmd.OpenForm "frm Company", , , "[ID] = " & [ID]
DoCmd.Close acForm, "frmCompanyDirectory"
End Sub
===================================
I used to have code on a button on the "frmCompanyDirectory" that added a new record to "frm Company" and that's when the ID = ID stopped working.
View 2 Replies
View Related
Apr 10, 2013
I have created a Datasheet Form which when opens shows lots of records. I was looking to see if there was a way that if i clicked on a specific field name within a record it would open a new form with all the information of that record only.
View 5 Replies
View Related
Jul 16, 2012
I have two forms. One is a datasheet. One is a form with a default view of Single Form (which contains combo boxes).I want to have the user select (click) on a record in the datasheet and have the second form open to that record. The datasheet form acts as an advanced search on two title fields.I tried the open form macro but I dont know how to have to second form open to a specific record.
View 9 Replies
View Related
Apr 19, 2015
How do I reference a subform DS field to open up a tabbed form on another subform.
Here's what I have.
field one on the Sub DS opens up tab one on another form, as does field two on DS open tab two on another form.
but..
how can I click on "any" field on the DS, run an IF statement, and it checks if that record on the Datasheet, contains information in regards to, IF field one OR field two contains any data, and opens the tabbed form respectively on the other form?
View 3 Replies
View Related
Jan 27, 2014
I am trying to create a proposal log for my company to make things easier to track. I have made a multiple items form to list the proposals. I want to be able to double click the record to open up another form (that i have already created) that shows the information from the proposal table and the proposal details table. So.....
I want to double click the field named "Proposal Name" and have it open up to form i have called "proposals details form".
View 3 Replies
View Related
Oct 10, 2013
I have a table that holds the SQL texts for ca. 1000 Select queries (mostly minor variants that are used to programmatically swap out RowSource strings for combo boxes). I'd like to have a quick and easy way to open/review/modify these queries.
One strategy would be to display the SQL strings in a field on a Datasheet form, then use an onClick event on a text box linked to the SQL-holding field (or perhaps an onClick event tied to an unbound text box on the form) to open the associated query. That would allow me to view the SQL of the query that I want to open, allow me to quickly scroll through the list of stored SQL texts, and give me options for sorting or limiting the SQL-texts displayed in the datasheet form.
But, I can't seem to get the onClick event to work. The problem seems to be that I can't figure out how to pass the SQL string contained in the field to a function that will use that string to open the query .
View 10 Replies
View Related
Feb 7, 2013
I have a textbox which I need to refresh when my Query is refreshed. Currently I only have the ability to requery with a Button but when that button is pushed I also want a text box to be refreshed. This is what I have currently in my On Click property of the requery button:
=[SearchSubformNew].[Requery]
Is it possible to have 2 On Click events? If so I just wanted to add the line to refresh my textbox which is named SummaryText.
View 3 Replies
View Related
Apr 14, 2015
I am trying to open a report (rptGMX-IRG) that includes a sub-report (srptRG) based on criteria that is set with two unbound fields on a form (frmGMXbook). This form has two dropdown boxes (cboGMX_No & cboMachSize) and a command button. The first dropdown box includes data located in the main form and the second dropdown includes data that is part of the sub-report.
I can get the report to open properly when I enter data into both fields on frmGMXbook.
However, the problem I am having is the inability to have one or both fields be "Like '*'" and show all associated records.
Here is the code I have on the command button.
Private Sub GMX_Preview_Click()
Dim strCriteria As String
If IsNull(Me.cboGMX_No) Then
strCriteria = "[cboGMX_No] Like '*'"
Else
strCriteria = "[GMX_No] ='" & Me.cboGMX_No.Value & "'"
[Code] ....
View 1 Replies
View Related
Nov 7, 2006
I have code for a button click event. Essentially I have a main table form that I use to enter customer data and info. I also have a button that I use to add that customer to a separate table that I use for special Customers. My code copies all the data I need copied to my other table, so I wont waste space here typing my code that actually copies the data to the new table. What I will list are the two commands I am using after that code, to close the current form (the one with the button) and open the form for entering special customer information (the form to edit data on my other table). It works flawlessly, but when it opens the other form, it opens to the first record. I want to know how to make it open to the record which I was viewing when I clicked the button to copy the data.
DoCmd.OpenForm "Special Customer Data Entry", , , Number = Me.Number
DoCmd.Close acForm, "Customer Data"
View 9 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
Dec 3, 2005
Hi,
As a part of reducing traffic on file server, I am planning to read less record on the form and hence I tried removing forms record source. (Attached sample db)
I kept all unbound textboxes onto the forms and save new record to the table using codes back of the command button. This is working great with main form. But doesn’t with sub form. I tried removing record source of sub form and keeping unbound text boxes to appear record if it exists.
If you enter 1 in InvNum text box on main form, you will find it brings record. I don’t want to show the record on the sub form unless I call it from main form.
How can I use the same trick of unbound text boxes with sub form too?
Please extend your help.
With kind regards,
Ashfaque
View 8 Replies
View Related
Feb 20, 2006
Hi All,
I hope someone can help me.
I have a table here tblTemp with a field client. This table can have from 1 to 100 records at times as it keeps getting cleared for the purpose of this exercise.
I also have a form frmLabel1Data with an unbound text box txtclient.
I was hoping to get the first record of the table into this text box upon opening the form.
I tried creating a query which gave me the following sql;
SELECT First(tblTemp.client) AS FirstOfclient FROM tblTemp;
I also tried placing it in this code with no luck
Private Sub Form_Open(Cancel As Integer)
Dim SQL
SQL = "SELECT First(tblTemp.client) AS FirstOfclient FROM tblTemp;"
MsgBox SQL
End Sub
Does anyone know why I cannot see the same result as when I open the query it gives me my client name but the code above does not????
Any help is appreciated.
Robert88
View 2 Replies
View Related
Oct 23, 2014
I would like to highlight record when user will click Record Selector in the continuous form. How to do it?
View 1 Replies
View Related
Jul 24, 2013
I have a report that tracks scores for our employees. From the report, you can click a button to add a new score in a form or edit an existing score(frmscoretracker). On this form there are two subforms, in a tabbed control to track additional information about the score; what areas were marked down(Trends), and was it a failing score(AutoFail).
When this form opens I have it programmed to only show the subform if there is data in it. The goal being, if I am adding a new score and there is no existing trends or Autofails for this new record, neither subforms will show - I will add an after update even to show either trends or autofail depending on the score recorded. Also, if someone chooses to edit the score, whatever subform with data, will show as well.
When someone clicks to add a new score, opening this main form to a new record, both of the tabs show. However, if the form opens to an existing record, the appropriate tab shows. Here is the code
Code:
Private Sub Form_Open(Cancel As Integer)
'If the subform has a record, the tab is visible, if not, the tab is not visible
If Me.frmtrends.Form.Recordset.RecordCount > 0 Or IsNull(Me.Trends) Then
Me.Trends.Visible = True
Me.TabCtl33.Visible = True
Else
Me.Trends.Visible = False
End If
[code]...
Both tabs are set as not visible in the default settings. Is there something in this code that is triggering then to be visible when there is no record in the main form?
View 4 Replies
View Related
Feb 20, 2006
Hi,
I want to show some text from another table based on the values of the bound fields in each record of a continuous form. I thought it would be easy, but I can't get it to work.
I step through the records in the bound recordset and use some of the values to query another table. Then I use the value from the query to populate the unbound text field.
It works fine for each record. But every time the unbound field is updated, all the records in the continuous form are updated.
I'm stuck on this one. It's probably something simple to fix - if you know what to do!
Do you have any suggestions?
Thanks!
-Daniel
View 10 Replies
View Related
Jul 21, 2014
I have created a form to select multiple records for a transmittal report. I added a button to the form which I would like to open the report to view the current record. In the On Click event I added the following code:
Private Sub cmdPrint_Click()
Dim strWhere As String
If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If
If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[TransmittalID] = """ & Me.[TBLTransmittal.TransmittalID] & """"
DoCmd.OpenReport "RPTDwgTransmittal", acViewPreview, , strWhere
End If
End Sub
The debugger keeps highlighting the row above shown in red. I've used this same code before on other forms and it worked but not sure why it isn't working this time. The only difference with this form and previous ones is that this form contains a multiple values combo checkbox (hope that's the correct term). The query that the report is based on changed the names of the field names so that TransmittalID on the form is TBLTransmittal.TransmittalID in the query.
I've tried the code with and without the extended name but each time the "Do.Cmd..." is highlighted.
View 11 Replies
View Related
May 17, 2015
I created an unbound text box on a form that automatically pulls the current logged in user by using this:
Private Sub Txtuser_Click()
Me.Txtuser = Environ("Username")
The form grabbs the logged in user with no problems, however, I ultimately want this information to also end up in my table. So the form has three boxes (to keep it simple). The user will type their first name and last name manually on the form which the record source is this "table" where their name goes to the table last name =Field 1 and first name=Field 2 respectively. I want the unbound box from the form to place the logged in user in Field 3 for the current record.
View 5 Replies
View Related
May 14, 2013
I have a form with 1 unbound listbox as drop down list (entypolst), an unbound text box(entypotxt) and a command button. The list box reads items from a table. I want to change a value (text) on listbox, input a text on textbox so pressing the button add a new record in a table (Table1 fields Category,Product) showing in my form as subform (SFTable1) in datasheet view. For that reason a made the following code:
Code:
Private Sub AddBtn_Click()
Dim ans As Integer
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
[code]....
I take the error msg for 0 items selected in listbox and exit the sub.
View 7 Replies
View Related
Jul 25, 2014
I have a button on a form and I want the On Click event behind it to check whether Shift is also being pressed when the user clicks the button (or Ctrl, or Alt, in fact any damn key will do).
I can't believe that there isn't a function in VBA like the old 1980s BASIC 'inkey' function (etc) that just simply returns the code of any key being held down at the time of the scan. I shouldn't have to mess around programming other events like KeyDown and KeyUp when I don't particularly need the key-press to trigger an event per se.
View 7 Replies
View Related