Changing Controlsource At Run TIme
Feb 20, 2008
I want to design a common Search Form which should read records from different table sources and populate a sub-form depending on the user preference. The recordsource of the form should change to point different table or query name depending on user option.
Similarly, the underlying text controls should have their control sources changed to appropriate field in the table selected.
How is this done in run time.
For example, I have two tables and forms (1) for Currency (t_CurrcyMas) and (2) for User details (t_USerMas). I have search form named frmSearch. This has criteria defined as txtCri1, TxtCri2. Depending on the entry of criteria, matching records should be displayed as continuous form in two text controls named txt1, txt2 under sub-form frmSubSearch. The recordsource of the form.frmsearch should be changed to t_CurrcyMas and control sources of Txt1, Txt2 to be changed.
WHat is the syntax for this, and in what event do I insert the codes.
View Replies
ADVERTISEMENT
Aug 29, 2005
I have a form. The form is bound to an underlying query which is a left join between two tables. (SELECT ... T1 LEFT JOIN T2 ON T1.RID = T2.RID ....)
Now, what I want to happen is the value in T1.RID does have a match in T2, then I want a sequence of text controls to be bound to fields from T2, otherwise I want them to be bound to fields in T1.
I almost have it working. I have Form_Current() and T1_RID_Change() both calling a routine
sub BindControls()
if isnull(T2_RID.value) then
txtField1.Controlsource = "T1.Field1"
txtField2.Controlsource = "T1.Field2"
' etc for each field
else
txtField1.ControlSource = "T2.Field1"
txtField2.ControlSource = "T2.Field2"
' etc for each field
end if
end sub
The problem is that when I change the value in T1.RID, most of the times it does change the controlsource appropriately. But other times it lags. It keeps the wrong controlsource until I try changin RID again, and sometimes the text boxes are just blank, so I am not sure what is going.
Am I ultimately going to be able to make this scenario work?
Thanks,
David
View 2 Replies
View Related
Dec 9, 2004
Hello again,
I think my subject heading explains it. How would you add or subtract two short time formatted values and produce a short time value? Also, how would you change a short time value into number minutes. (i.e. 5:30 into 330) Thanks!
G
View 1 Replies
View Related
Jun 10, 2005
Are there any tricks or formats out there that make updating a time easier. I have a date field (Formatted: short time and input mask: 00:00;0;_)
When I put in the original time it does great. When I try to change the time I have to delete the old time, go to another field then come back and put in a new time. If I do anything else it rejects and beeps (annoying) and tells me that I am not using the proper format.
View 1 Replies
View Related
Jun 4, 2014
I have a small issue, but cannot solve it. I have a form with a textbox bound to a time(7) on a SQL server linked table.
Even if I put the format as "Short time 24h" or "hh:mm" it will always come out with seconds, nanoseconds, etc as soon as you change record. I would like to avoid using the "current" event to keep the "hh:mm" at any record change.
View 4 Replies
View Related
Dec 13, 2007
I have a unbound text box being used as a label. In the control source of the text box I have a date ie. =#12/31/2008#. I am using this date for criteria in a dsum function, so whatever date is in this field effects the data being displayed. I need to be able to have the user edit this date when necessary. I created another unbound text box and put the following code in the after update: Me.ReestDate.ControlSource = "=#" & Me.EnterReestDate & "#"
This is working as it is displaying the correct change. My problem is that the control does not retain the date. When I exit out and go back in, the original date is still there. Is there some code that will save the field after I update it? Or maybe another suggestion to do what I need.
Thanks
Gregg
View 3 Replies
View Related
Aug 19, 2004
I am trying to set a ControlSource for a textbox to a string what is the correct syntax?? I am also trying to set a record source using DLookup, this is also not working. Could some look at my syntax an correct me.
Reports(!strReportName)!txtClientName.ControlSourc e = "All"
Reports(!strReportName)!txtClientName.Value = _
DLookup("[ClientName]", "CLientIDs", "ClientNumber = '" & _
Forms!frmReport!txtCustom1 & "'")
thanx
View 2 Replies
View Related
May 24, 2007
There are between 10 - 15 users at one time. It is a shared network, the front_end is on individual hardrives and the tables are located on the server. We just converted to Access 2003, our data file size is 47kb.
Users who are not active in the database get disk or network error message and have to close out. Is idle time a possible factor? Some users maybe entering information sporadically through out the day, but need to have the database open, they may need to refer to a member record upon receiving a phone call.
:confused:
View 4 Replies
View Related
Mar 31, 2014
I have a date/time field on a form that has the default set to "=now()" which puts in the system date and time. I need to change it so that the date changes to the next day any time after 11:00 PM (instead of midnight). This is because our third shift starts their day at 11:00. If they start entering data right away, alot of their work shows up on the wrong (to them anyway) workday date. I'm struggling with the expression builder to get this to work.
One way is changing the time to be an hour ahead but that will affect the entire day when I just want to change the date for one hour per day.
View 3 Replies
View Related
Jun 26, 2013
I am having difficulties changing a date/time field like '22/04/2013 09:14' to make it look like '2013-04-22 09:14' using a query.
View 3 Replies
View Related
Feb 5, 2014
I have an access database and I plan on splitting it so the FE will be on each users workstation and the backend will be in a folder on the server. But is there anything else I need to do to allow for the possibility of multiple users using the database and changing info at the same time?
View 4 Replies
View Related
Jan 28, 2008
I am trying to set the controlsource propert within VBA for a combo box
S_SECTCOSTCENTRE is the field name I want to set.
My syntax below doesn't work can anyone help
cmbcostcentre.ControlSource = "S_SECTCOSTCENTRE"
thanks paul
View 1 Replies
View Related
Nov 4, 2005
I have a form with two subforms. One of the subforms has five subforms (subsubforms).
The ControlSource and the (query sequence for each) RecordSource of each of the subsubforms are created on-the-fly. The subsubforms have no Master/Child relationships specified. The subsubform merely display various filtered and various grouped subtotals of the 1st subform. Summing and grouping on the subsubforms prevents my using Master/Child properties.
On the AfterUpdate event on any of the filter fields on the form the ControlSources and RecordSources are rebuilt and the form becomes invisible for some reason and appears to hang, even after stepping through all the (class module) code with the debugger. Repeadedly clicking both Maximize and Restore buttons on the form's button on the Status Bar followed by clicking a 2nd form's toolbar icon causes the form to become visible under the 2nd form. The tool bar are also not visible, just a large brow bar at the top of the form. Moving the mouse over the toolbars causes individual icons to become visible or raised.
What am I missing?
Maybe I should calculate the values using DAO recordsets and backfill unbound subsubforms.
Thank you in advance for your thoughts.
View 1 Replies
View Related
Mar 31, 2008
I have a combobox that selects the customer and shows related information on that customer such as phone number, cc#, etc..
now the trick is i need to allow the selected member to be added to the order information.
For instance, the user selects the customer "Bob" and bobs information is displayed to check for accuracy. After the info is approved the user will continue to process his order. In order to do this I need the customer ID to be the same as the selected customer in the combobox.
Then the user will proceed to fill out the order information, location, date, time, etc.
How can I go about doing this?
Thanks in advance
View 2 Replies
View Related
Feb 2, 2014
In my application I have continuous form with unbound textbox. In OnOpen form event I change ControlSource property of textbox to one of the fields (e.g. "Kol921") in forms recordset. In form footer I have another unbound texbox where I defined ControlSource property as "=Sum([Kol921])".
Values in fields shows correctly, but in "sum" textbox I get Error.
When I get through code in debugging mode (with F8 key), value in "sum" texbox shows correctly, but when I open form normally I get an Error in that textbox.
Here is part of code:
Me.Controls("mat1").ControlSource = "Kol921"
Me.Controls("mat1").Visible = True
Me.Controls("matSum1").ControlSource = "=Sum([Kol921])"
Me.Controls("matSum1").Visible = True
View 2 Replies
View Related
Jun 11, 2013
I have multiple reports that use similar IIF statements as the controlsource for four textboxes. Naturally, I don't want to have to update twelve controlsources if any of the calculations change, so I thought I'd make this a public function. However, I don't know how to pass along multiple textboxes as variables. Here's what I have so far:
Code:
Option Compare Database
Public Function txtColor(ByRef textbox As Control)
Dim str1, str2, str3, str4 As String
'The IIf statement is simplified for this example. It's not important.
str1 = "=IIf(IsNull([Inquiry start date]),'W',IIf([txtInquiry]<1 And IsNull([Inquiry end date]),'R'))"
[Code] ....
And this is in the report (where ??? is what I'm asking about)
Code:
Private Sub Report_Load()
Call txtColor(???)
End Sub
The error I get is "Runtime 424 Object Required"
View 7 Replies
View Related
May 23, 2006
I have an application with a backend db on PC 1, and the same application on PC 2 linked to the backend db on PC 1 via the network.
The link works fine but the time formats are different.
On PC 1 the time format is shortime and displays as it should i.e. in 24 hour clock format
However on PC 2, opening the same database via the network, the time format is still shorttime but when you read the time within the code it comes out in AM/PM format. Also, when the defaul tiem should be #20:00:00# but this changes to #8:00:00 PM#
Weirdly though, when you just open the table, the times are in the correct shorttime format.
Guessing, it must be a setting within the main core of Access 2003 that is different between the 2 instances?
Any ideas?
This screen shot may help:
View 2 Replies
View Related
May 23, 2006
I have an application with a backend db on PC 1, and the same application on PC 2 linked to the backend db on PC 1 via the network.
The link works fine but the time formats are different.
On PC 1 the time format is shortime and displays as it should i.e. in 24 hour clock format
However on PC 2, opening the same database via the network, the time format is still short time but the format is in AM/PM or medium time.
Guessing, it must be a setting within the main core of Access 2003 that is different between the 2 instances?
Any ideas?
View 1 Replies
View Related
Nov 8, 2013
I have a database that stores information for lab testing. Each time a tech does a "step" in the test process he logs it in the table, using an input form. There are different categories, for example preparation, testing, analysis, etc, and each of those steps take time. I have the form autopopulate the date and time with NOW() evertime the form is updated. What i want to do is calculate the time it takes to do each in days. I can easily get how many days it was from now since they logged the test, =NOW()-TestDateTime. What I want to do is get the number of days it took to do each step, ie the number of days between each event. Is there a way to do this?
View 3 Replies
View Related
May 6, 2015
how to be able to enter time in access form the same way as if would be an access table (1p = 1:00 PM; 1.25 = 1:25 AM etc)
View 1 Replies
View Related
Apr 3, 2014
I have an attendance database and I connect the time attendance machine db to my access db, what i am trying to do is to generate a report that shows the time in and time out for specific date. the type of attendance db is date/time.
Please see the attached screenshot db from attendance machine.
an also some time there is duplicate entry, I need to get the first and the last entry only for specific date.
View 4 Replies
View Related
Dec 3, 2013
Formatting issue regarding elapsed time calculated using DateDiff().
I understand that you can specify the output value for DateDiff(). In my case I have chosen "n" for minutes. Each result in my query shows the correct calculation in terms of minutes.
[PunchIn] = 11/23/2013 8:11:28 AM
[PunchOut] = 11/23/2013 5:43:30 PM
[ShiftLength] =DateDiff("n", [PunchIn],[PunchOut]) = 572 minutes.
Now when I try to format the result in terms of H:MM (be it in a form or a report) I get varied results. I'll illustrate an example below:
=Format(([ShiftLength]/60),"0") & "." & Format(([ShiftLength] Mod 60),"00") Returns 10.32 Not correct
=Format(([ShiftLength]60),"0") & "." & Format(([ShiftLength] Mod 60),"00") Returns 9.32 This is correct but I need my result to be in the form of a decimal such as my next example
=([ShiftLength]/60) Returns 9.53333333. Getting there but how do I have this result only show two decimal points 9.53?
View 6 Replies
View Related
Aug 29, 2013
I have a date/time text field on a form with the General Date format and a combo box next to it that has sequencial times as the row source (IE. 12:45 AM, 1:00 AM, 1:15 AM, 1:30 AM, ETC.) When the user chooses a time in the combo box, I want the time portion of the text box to be updated with the chosen time in the combo. I have tried a few things but cant seem to get it right.
View 4 Replies
View Related
Apr 10, 2015
so i created a system to have events booked, and i am trying to check time availability of the event room available, but i dont know what wrong. it either my query or vba code. i have attached the attachment,
View 5 Replies
View Related
Dec 1, 2013
I have a working dB which can calculate a shift duration and sum total all shifts worked within a period for the purpose of producing a labor report for payroll. I have successfully used the DateDiff function and converted the minutes to HH:MM on my form and reports. Now I want to calculate elapsed time for a specific period within a shift, I'll call it OtherHours and I am aiming to calculate a portion of time that meet the following conditions below. I am using field names of [PunchIn] and [PunchOut] and both are of type General Date.
IF [PunchOut] ISNOT Saturday,Sunday
EXIT FUNCTION
ELSE
IF [PunchOut] ISNOT Between Midnight and 0559 hours
EXIT FUNCTION
ELSE
DATEDIFF ("n", <MIDNIGHT>, [PunchOut])
My thoughts are to solve the DateDiff portion and then figure out how to apply the conditions within the IF statements.
View 4 Replies
View Related
Aug 22, 2012
I have a database consisting of two tables. One is "articles" and the other is "tasks". To put it simply, I would like to find how much time the article spends in tasks, but one article can have many tasks, and they often (but not always) overlap. Tasks have a start and end date field.
View 8 Replies
View Related