Copy Field Value To Variable?
Apr 2, 2008I'm sorry to have to ask such a basic question, but I'm having trouble figuring out the syntax for saving a field value, in the current record, to a variable. I appreciate the help.
View RepliesI'm sorry to have to ask such a basic question, but I'm having trouble figuring out the syntax for saving a field value, in the current record, to a variable. I appreciate the help.
View RepliesI am trying to copy the parameter value that is entered to a variable so that it can be used to run other queries without typing it in over and over. Once my form is finished it will run 4 queries, and the current setup is that I would have to retype the parameter each time.
View 9 Replies View RelatedI am creating a 2 level report to confirm an order. Main report already created, runs successfully called as subform/subreport under "OrderDetails" form. Linked to master using Order.ID. There are two versions of the confirmation report that have different layouts for different program types.
The hangup comes when I try to add a "Class Dates" subreport. It lists dates of individual classes and Skip dates. I have created the subreport as "srClassDates". When I add it to the main report, it lists the records. However, when I try to link it to the Main report, an error message box appears with the "object variable or With block variable not set".
I have tried rebuilding both the main and subreports, rebuilt the query, have not found anything that changes the result.
Linker has been working successfully on other subforms. Report with groupings works fine, but I need data from 2 tables both linked to order.id.
I have a folder which holds 1000s of pictures organised in subfolders, for example:
D:~AI Database Print Scans2009family and
D:~AI Database Print Scans2009holiday
And so forth. In total at the moment 17 main subfolders, each of which hold another 2-3 subfolders.
I am putting together a database to bring pictures together with all sorts of details. I import the picture via hyperlink and complete the various fields. All that works fine but there are a lot of pictures! And it gets confusing to see which ones have already been entered into the database and which ones haven’t.
One solution for this is to copy the pictures that have been “completed” to another folder. I have found a way to do that:
Dim fs As Object
Dim oldPath As String, newPath As String
oldPath = Forms!frmPrintDetails.txtPath1
newPath = "D:~AI Database Print ScansCompleted_Entries"
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath, newPath
Set fs = Nothing
Works fine, but the problem is that I loose the subfolder structure, it copies all pictures to the same main folder. I’d like to maintain the subfolder structure and add code to create the correct subfolders and next copy the picture. With the different paths I’m lost. I don’t know how to extract the correct path in code. I’d also like to either rename or remove the picture once I have completed entry of the details. The problem I have again is that I don’t know how to code for a changing path.
How can I get the value from a field in one table (in the sub form) to copy/insert into a field in another table (in the main form) when adding a new record?The main form and sub form are linked using parent/child linking, and the sub form is in a tab.I have table A (Visit Dates) in the main form which is used to record the date of a visit to a church. Table B (Quarters and Peals) is used to record an event that took place at that church during that visit. Note that not all visits in table A require a record to be created in table B - but half or more do.
In tables A and B I have a field called "QuarterOrPealID" and these are both primary keys, though the field in table B is set to 'no duplicates' and in table A it's set to 'duplicates allowed', as table A has its own auto number/pk. They are both linked in the relationships.
So, when I add a new record to table A using the main form, I might then need to click on the tab in the sub form to create a new record in table B, which has to be linked to the same record in table A. When the "QuarterOrPealID" auto number/pk is generated in the sub form (table B), I need that value to update to the "QuarterOrPealID" field of the main form (table A), so that when I'm viewing these records the form pulls all the information nicely together.
I have a form and a VBA event in which I would like to update a field in the current record. However, the field name is stored as a variable so I can't just use Me!FieldName = __
I've tried simply the following, but get a "No current record" error. why I'm getting the error, but how do I select the record currently visible in the form to edit?
Code:
foo = "bar"
Me.Recordset.Edit.Fields(foo) = True
Okay. I am certain that I am missing something real easy.
I have a somewhat large, form. I needed to offer users a similar form, but with a few field changes.
So, I copied the form, added the new fields.
If I work with an existing record and do not change the 1st field's data (idnumber), then no problem.
BUT if I try changing that idnumber or adding a new record, I cannot exit that 1st number.
There is no afterexit info for it or other issue that I can see. (But am I 'blind'?)
I appreciate any ideas.
Russ
My table called Table1 has a primary key field (called RefID) with AutoNumber format. My problem is I want duplicate value of RefID field to another field called DupID. I want DupID to be changed, but I don't want any change on RefID field whenever I make changes.
View 5 Replies View RelatedI'm working on a module which determines which the previous and next task for the part is. To do this the module finds the first record where the previous field says 'none' and puts the following into variables; the ID for the part (WoTasksFID), The routing number (TaskNumber), the job that is being completed at this stage (Shop), and the task order ID (TaskOrderID). I then want it to find the first record which has the same ID for the part and has a TaskNumber that is one smaller (This is where the error in my code occurs). I record the same variables as before (this time with a prefix "Prev") and use the information to fill the previous and next fields for each record set.
Like I said, the error occurs when I am trying to match the WoTasksFID - instead of finding a field with the same WoTasksFID, it seems to choose the first field in the table no matter the value. Here's the function:
Code:
Function PreviousTask()
Dim TaskOrder As Recordset
Dim WoTasksFID As Integer 'For Current Record
Dim TaskNumber As Integer 'For Current Record
Dim Shop As String 'For Current Record
[code].....
What am I doing wrong?
I have a data entry form with many records. Instead, of retyping the same data. I would like click a button and the data on the top row will copy downward.
View 3 Replies View RelatedError 91 - Object variable or With block variable not set
I am getting this error telling me that an object variable is not set.
I know which variable it is but when I step through the debugger it sets the variable and all is fine? Issue is that public variable of a class is not getting set when the VBA Editor is not open?
This code runs fine the FIRST time, however trows up a message the SECOND time it is run.
The error is on the line ".Range"
I am trying to sort records which have been exported to Excel.
Dim LR As Integer
LR = 5
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set wbRef = xlApp.Workbooks.Add
With wbRef
wbRef.Activate
.Worksheets("Sheet1").Activate
With ActiveSheet
.Range("A2", .Cells(LR, "O").End(xlUp)).Sort Key1:=.Range("C2"), Order1:=xlAscending, Header:=xlYes
End With
end With
I have requested this before but the example given did not fit my situation and I had a heck of a time trying to adapt the example given to me so I will step by step describe what I need. thanks...
Can someone show me how to do the following:
1) Take a combo box that looks up a table that has 2 variables (Var1 and Var2).
2) Depending on the value chosen in the combobox (Var1) then a text field will automatically have the value (Var2) appear.
3) This information from combo box and text field will then be stored in a separate table that is linked to the form.
__________________________________________________ _____________
Also:
Is there a way to extend this example further by adding another combo box that takes the result from the first combo box to filter in values for the second combo box which will then automatically populate a text box which would then be stored in a separate table.
__________________________________________________ _____________
Someone kind of showed me before but they used unbound variables and this confused me as the combobox was unbound but how is that information stored into my table?
Pardon me for my redundancy but this is frustrating me to no end and I unfortunately have a deadline of today!!!! :(
I think it is the row source thing that confuses me. I take row source to mean where the data is stored. But where do you identify where to obtain the data to then store in your "inputed" table?
I have a large problem that i need to get figured out ASAP! I have a form text box (named actual cost) that needs to pull a specific record from a table
Now in this table it has multiple rows according to each job. There is a text box (Project number) that has the project that this (actual cost) box should pull from the specific row in the table.
if anyone can help me it would be the biggest help.
-Thanks
Jon
I need to have the comparison variable (< or >) to be read from a field in the form.
Namely:
WHERE (((([PackagesCosts].[TotalCost]) & [Forms]![F_Reports]![Increased] & [C].[TotalCost])
Where [Forms]![F_Reports]![Increased] is the filed on my form.
What is wrong in the syntax (as it is not working properly)?
is it possible to name a field in a query or a table with a variable name?
For example:
I want to choose in listbox "fieldname" the name of the field.
And the query field name looks like:
Code:
forms![testform]![fieldname]: FieldOfTheTable
Unfortunately it doesn't work.
Also if I save the choosen fieldname in a vba function.
Code:
fieldNameFunction(): FieldOfTheTable
This doesn't work, too.
I am looking at copying one field to another (held in a different table) by using a command button. I've applied to following code to the OnClick event of the command, but it doesn't seem to work and I'm not sure if you can actually copy between two different tables :
Private Sub Command59_Click()
[enquiry_mainsite]![mainsite_unit] = [enquiry_entity]![entity_postalunit]
[enquiry_mainsite]![mainsite_streetnum] = [enquiry_entity]![entity_postalstrnum]
[enquiry_mainsite]![mainsite_street] = [enquiry_entity]![entity_postalstreet]
[enquiry_mainsite]![mainsite_suburb] = [enquiry_entity]![entity_postalsuburb]
[enquiry_mainsite]![mainsite_state] = [enquiry_entity]![entity_postalstate]
[enquiry_mainsite]![mainsite_postalcode] = [enquiry_entity]![entity_postalcode]
End Sub
This code is basically trying to copy fields from the enquiry_entity table to the enquiry_mainsite table. Does anyone have any insight to if what I am trying to do is fesible?
Hello,
I need to be able to copy the last part of text from 1 field to another.
Speciffically,
yadda yadda (ABC)
to become:
+ field1 + field 2 +
| yadda yadda | (ABC) |
(ABC) is not always of length 3, it could be (XY), (T) or more.
can someone help me with a method to strip this into another field?
thanks!
After the Portfolio Code has been chosen how can I place the "Broker Code" into the field = Broker
View 13 Replies View RelatedI have a field called Shipdate. I have created a new field that is called invoicedate. What I want to do is copy all of the shipdates and paste them in the invoicedate field for my old records. From here on out they would be distinct fields but for old records and reporting purposes I need those dates.
Can I do that in a query, do I need a module???
It's probably easier than I think it is.
Thanks.
I need to make changes to a table already containing data. Currently the autonumber field is simply there as a primary key, but I now wish to use it for another number field (Accession No) which was previously completed manually.
As this doesn't seem possible or practical (as I need the flexibility to overwrite the number sometimes), I just want the autonumber to also appear in the Accesion No field when a new record is added (but be manually overwriteable).
I've had a play with default values and lookups, but with no success, and haven't found anything on the forum. Where am I going wrong, or is this just not possible?
Thanks for your help.
Alison.
Im using the UPDATE Query in Access
UPDATE MAT_Clean SET FCODE = 'BC', NOTES = 'HC RAMP'
WHERE FCODE='BC HC RAMP';
Instead of typing what needs to go into NOTES everytime, how can I specify whatever comes after 'BC' to go into NOTES? Use 'BC *'?
Thanks!
Hi
I have read through this forum and found some help on this but can't get it working.
I have a subform
Activity
Contains a tab control with two tabs
Activity Details - Persons
I want to copy the address field from Activity Details tab to the Address field on persons tab
Code for the on click even twon't work. Can't find errrors. I know it is because I haven't referenced it properly.
Me.txtpersonBuildingNameNo = Me.txtactivityBuildingNameNo
Any help :)
I have a form that resembles a spreadsheet and have data in certain fields that is longer than the field is wide. (The widths are set according to client preference and widening the field is not the solution.) I was thinking perhaps I could use the status bar to show the data when the focus is on that particular field. Right now, the only help on the StatusBarText topic that I can find indicates that the status bar can be "programmed" with static text only, but I was hoping to make it dynamic, depending on the field in focus.
If this is the wrong approach (i.e. can't be done), does anyone have any ideas about how to use an external control to show (and possibly edit) data on a spreadsheet-like form?
The client has been using MS Works and is being dragged into Access only if the transition isn't too painful (for him, lol) and having an ability to look and feel like the Works interface is important to him.
Thanks,
- Terri J.
I would like to copy the Data from the field PORTFOLIO CODE into the field BUYSELL.
I would like to copy the CURRENCY Data in the field STOCK EXCHANGE into the field CURRENCY
We use MS Access 2007.
I have form with the following fields
ID
Added by
Agent Name
Sign on
AgencyName
PCC
AgencyName (From another table)
PCC (From another table)
I need to copy the data from first AgencyName to second AgencyName and first PCCto second PCC
how can I do this with macro?