I am trying to reference a field on a sub form from a button on the main form. I want to read a field called "Date1" and I want Date1 from the first row, regardless of which row has been selected by the user. The statment used is
and wanted to change this. I have this on the On Current event and it gives me an error because the data is not in the record source when the form opens. How can I change the me. to the formname? The form gets dynamically created so i have
Dim CurrentForm As String CurrentForm = Me.Form.Name
then i put
GBL_Tab05ID = Forms(CurrentForm).Form.Tab05ID
but that did not work...what is the correct syntax?
I am working on an form (using Access 2000 and VBA) that stores registration information, along with events that were attending, in a table and later retrieves that same information from the table to display the regist. info, events attended, and allows the user to change any current info along with adding new/recently attended events to each record. I am currently allowing a max of six events, along with event details, to be stored and I am running through six different if statements to match the Event_List (name of the combo box that contains "Event 1 Event 2...Event 6") to the appropreiate information in the table. I have started to simplify the code to remove the redundancy by running a Do While to to find the correct Event by using an integer variable that starts at 1 and is incremented until it matches the 7th character (the number portion) of the Event chosen from the Event_List. After this I want to use that integer variable to say what event information in the table to gather. My problem is this: I have tried many different varieties of the following code and I am unable to make it work. I had never used Access up until a week and a half ago, and a few days ago I went and bought the book "Access VBA Programming for Dummies" but it doesn't help for this problem. Here's part of the code:
Variables (Event_Name, PMT, Receipt, Payment_Type, PIF) refer to Form textboxes while the variables in the [] refer to table field names.
'------Code I'm Currently Working On------- Dim intX As Integer Dim EventVal As Integer Dim strX As String
intX = 1 EventVal = Val(Mid(Event_List, 7, 1)) Do While EventVal <> intX And intX < 6 intX = intX + 1 Loop
strX = str(intX) Dim E_Name As String Event_Name = [Event strX ] PMT = [PMT strX] Receipt = [Receipt strX] Payment_Type = [Payment Type strX] PIF = [Paid In Full strX]
'-----Old Code That I'm trying to simplify------- If Event_List = "Event 1" Then Event_Name = [Event 1] PMT = [PMT 1] Receipt = [Receipt 1] Payment_Type = [Payment Type 1] PIF = [Paid In Full 1] Camp_Site = [Camp Site 1] Cabin_Number = [Cabin Number 1] ElseIf Event_List = "Event 2" Then Event_Name = [Event 2] PMT = [PMT 2] Receipt = [Receipt 2] Payment_Type = [Payment Type 2] PIF = [Paid In Full 2] Camp_Site = [Camp Site 2] Cabin_Number = [Cabin Number 2] ElseIf Event_List = "Event 3" Then Event_Name = [Event 3] PMT = [PMT 3] Receipt = [Receipt 3] Payment_Type = [Payment Type 3] PIF = [Paid In Full 3] Camp_Site = [Camp Site 3] Cabin_Number = [Cabin Number 3]
In my form (source tblJobs) i input a contract number from tblContracts. but i would also like it to show the contract address when the contract number is entered. Both fields belong to tblContracts but i only wish to enter the contract number, the address will just be used as a reference as it isnt something i would have to enter again.
So for example
112 - Main Road
If i enter 122 in my ContractNo field i would like it to show the contract address for that specific contract.
I have a large table that is appended daily. I need to be able to specify two dates, a start and an end, and pull only the records in the table with those dates. There will be two records for each account number, one from the specified start date and one from the specified end date. I then need to calculate the difference between a value in a single field from the end date and a value from the same field from the start date. DLookUp will not work because there is an input parameter. How could I accomplish this task?
I have 10 fields on a subform. they are named value1 to value10 consecutively. I would like to loop thru them, and get their values to use in subsequent events. I tried the following to reference them...
Dim iLoop as integer Dim fldVal as control Dim ItemValue as string
For iLoop = 1 to 10 fldVal = ("Forms![Form 1]![Subform 1]!value" & iLoop) ItemValue = fldVal Next iLoop
I also tried a couple of other variations, but cannot get this **** thing to work. Any help would be appreciated.
I have a form bound to a query. The query result has a field that I would like to reference, however I do not want the field on my form. Is there a way to reference a field in the query results that is not on the form?
When entering a lookup reference to a table field it pop up message saying, "you can't modify the table 1 this time as it is in use by other person or process" i have closed all forms and table reports but the problem is same to rectify ? also when going to see the realationship then there shows no relation ship developed even after the lookup reference from one table filed to another table field.
I have two tables, Table 1 and Table 2 and two related forms, Frm1 and Frm2. I want to be able to update the data on Table1 from Frm2, that is, if I change the data on Frm2, the corresponding fields in Table1 will update to the same data. I know that if both tables are open I can reference the fields on Frm1 and Frm2 with an IF statement: If Active = True And Forms!Frm1a.DoNotchange = False Then..And I know on the update query I can reference a control on a form by Forms!Formname.Control. Wll works fine.What I would like to know is can I reference a table field in the same way. For example, I have tried to use the IF Statement If Active = True And Tables!Table1.DoNotchange = False Then..Is there a way to reference the Table instead of the Form in both the VBA and the query? The problem seems to be that I have the two bound controls [Active] on Frm2 and [DoNotChange] on Frm1. (Which I need).
Loc Company Pack RoundedNum SumTotal 2 ASDA AA 1 2 ASDA AA 5 6 1 Asda AC 2 2 1 ABC BB 10 1 ABC BB 1 11 2 XYZ AR 1 1
I am trying to achieve "SumTotal" column result. In the above query RoundedNum is an expression achieved from other columns(not shown above) from the same querytable. Now I want to insert this "SumTotal" column which will count for Total RoundedNum as per same type of Packs.
Thus the Total Field should look like the one shown above. Any idea how can i achieve this? :confused:
I would like to update two fields [Category] and [ProdType] in tblAccum based on a reference table.
The reference table is tblReference and contains the fields [Code], [Category] and [ProdType].
tblReference example of field values:
Code Category ProdType A Blank Accessory BS Blank Blank Stock O Printed Offset
So if the Code field in tblAccum has a value of O then based on the tblReference table the Category value would be Printed and the ProdType value would be Offset.
I have an access db that is linked to a sharepoint list (the list originated in Access).I tried a simple select query with parameters to search for by id and another query of the same table to search by date.They both come back with the same error of "cannot reference a table with a multivalued field using an IN clause that refers to another database"Iv'e gone through the table and these fields that the query is using and none seem to have any multivalues.
I have a query which gets information from 2x tables where the I'd on one table is the reference number on the second table.I would like to know how I can remove the duplicates on my reference number field?
I have a form/subform that requires some fields from the Switchboard for its criteria. Last week due to no action on my part, it started asking for those values as Parameters instead (Forms!Data!txtInspDate), etc! The new form loads, but of course it is blank with no data. This happens if I load it from a command button or from the navigation sidebar... UNLESS I first load the switchboard in Design Mode, go to VBA window, then reload the Switchboard in Form Mode and press the button. From then on until I close the database, everything works fine!
I have placed an unbound subform on a form. I have the following code which loads in different datasheet to the subform:
'Loads in NewQuery Me.data.SourceObject = "query.NewQuery"
'Loads in NewQuery2 Me.data.SourceObject = "query.NewQuery2"
etc.... this works fine to show these queries but i want to know how to reference the fields on the datasheet.
for example one of the fields in NewQuery is "ID"... When clicked i want to run code... normally on bound subform i could go for example ID_Click()... msgbox(me.ID)
how can i reference these other fields on unbound???
I want Access to automatically generate a reference number for a record based on the values in on two other fields for a given record using a form.
The first field is called Operation Number.
The second is Bag Number.
The reference number needs to be in this format: 19C.3.1
Where 19C is the Operation Number, 3 is the bag number, and 1 is automatically generated. Additionally I need the last number --the automatically generated one--to go back to 1 if with each new bag number.
This is kind of like library catalog numbers. Not sure how to do this.
I'm stumped and spinning my wheels like so many Milwaukee drivers after yesterday's snowfall. I have a series of forms named Survey1, Survey2, Survey3, etc. I also have a form for recording notes. When I close the notes form it is meant to post the notes into a hidden memo field on the survey form I am working with. I would like to keep the number of notes forms to one. I would like to refer to the survey form dynamically. Currently I am trying something like:
Dim SurveyForm As Form
Set SurveyForm = "frmSurvey" & Forms!frmMainScreen!SurveyDID
Forms!SurveyForm!MEMO1 = Forms!frmFreeText!Text0
I keep receiving an 'object required' error. Has anyone done anything like this? Can it be done? How?
I have inherited maintenance of an Access DB that I did not design and I'm having trouble with their Navigation Form setup. I created a form with a list box and two date fields, and figured out how to build a filter for the form that would open a specified report on a button click. It worked great as a stand-alone form, but when I added it to a navigation control in a navigation form I can't seem to find the right path to tell the VBA where to look for the filter criteria.
In the screen shot, the report to be displayed is in the detail of the "Report Center" tab on the far right of the navigation form "Main." the form "FilterSelection" is inserted in the "NavigationControl0" section under the navigation tabs. Criteria is selected/entered in "FilterSelection" and needs to be passed to the filter of the report that is opened when the "Project Tasks" navigation button is pressed. As I mentioned, when I created the form I put a button on it to open the form with the filter (built via SQL in VBA) it worked beautifully. But now that it's on the "NavigationControl0" object Access errors and can't find the fields where the data has been selected/entered.
I have a DLOOKUP which is used to auto populate a field on my Income Commitment Form based on a field on my Expenditure Commitment Form.It works perfectly when you enter a new commitment.Currently you enter a new Expenditure Commitment, save it but don't close it, then from the Expenditure Commitment Form there is is a button to enter a related Income Commitment. You save the Income commitment then close it, then close the expenditure form and you are on the Client screen with both these forms now showing as subforms, both have record selectors.
My issue is, that sometimes the Expenditure Subjective can change, so from the client form you use the record selector to open the Expenditure Commitment and select the correct Subjective, you then save it and close it. You should then click on the Income Record selector which opens the income commitment, but when you re-click on the Combo42 button, it doesn't reselect the Income subjective and I think it is because the Expenditure Commitment which is what it is looking up isn't open. My issue is how do I get the DLOOKUP to work and refer to the Commitment Form if it is a new commitment, or the Subform if I have gone back in through the record selector.Here is the code I have.
Private Sub Combo42_AfterUpdate() If (Me.Combo42 = 1) Then Me.IncomeSubjective = DLookup("[Subjective]", "tblIncomeSubjective", "[ExpSubjective]='" & Forms![frmCommitments]![cmbSubjective] & "'") Me.OtherIncomeConfirmed.Enabled = False Me.OtherConfirmedBy.Enabled = False
I have form named SearchForm and there is unbound subform named Search_blank. Depending on button in menu is used source object of Search_blank. One of the source objects is form named MeasureForm and it has subforms named MeasureForm_sf1 and MeasureForm_sf2. How can I reference public sub in MeasureForm_sf1 from SearchForm? How can I reference public sub in MeasureForm_sf1 form MeasureForm_sf2?
There might be a problem with unbound form. I tried reference public sub named GetLastVal from SearchForm that is in MeasureForm:
Code : Me!Search_blank.Form.GetLastVal
and it was working. Than I tried reference public sub named GetLastVal2 from SearchForm that is in MeasureForm_sf1: