How To Pull / Push A Value From Current Form To A Function Using VBA
Dec 26, 2012
Using the code below I am able to open an explorer window from access and select most of a file path. The part I am not able to get is "LN" which is a field in my forms. I need to be able to pull the current LN number into my Modules file path. How do I do this? Is it easier to go by ID or the actual field I am looking for?
Code:
Function Loan_Folder_Search3()
Dim rs As Recordset
Dim LN As String
Dim Client_Name As String
Dim RetVal As String
Dim LFPath As String
[Code] ....
Currently, it keeps pulling the first record, no matter what record I'm on.
View Replies
ADVERTISEMENT
Sep 10, 2007
I searched the archive and didn't find quite what I was looking for, so..
I have an Excel 2003 spreadsheet work-in-progress being used as a template (developed by others) to prepare project cost estimates in a complex regulatory environment. We are 'modelling on the fly' for a number of projects until we are comfortable with the estimate model, after which time I intend to incorporate our 'stable' estimate methodology into Access. Meanwhile, I am 'stuck' with the Excel spreadsheet.
I have a project tracking database (Access 2003), and I want to be able to track my estimates. I do NOT want to embed my spreadsheets into the db, just a filelink. There can be more than 1 estimate per project.
Ideally, the user should be able to define a project in the Access db (or select one already defined) and click a 'make estimate' button, which would generate a new Excel file in a predefined directory (based on the present version of the .xlt file), give it an appropriate filename (based on the Access ProjectID and estimate sequence number for that project if there were others already), open up that workbook in Excel, and then autopopulate some cells based on information showing on the original form in Access!
A separate button for 'Open existing estimate' will eventually be required, but I think I could do that if I can get someone to walk me through the steps required above.
I am somewhat familiar with vba in Access, but am an absolute rookie when it comes to excel.
Edit: I left out that I would also add an appropriate record to a table like tblEstimate which would contain the link(s) to the estimate(s). This table will obviously contain a FK to tblProject
View 1 Replies
View Related
Aug 16, 2014
I want the Query Criteria to pull its value from a control on a form.The form control either has data or is null. (My problems occur when the form control is Null). The field in the table either has data, is null or is blank.
Code:
=IIf(IsNull([Forms]![FormName]![FormControl]),"" Or Is Null,[Forms]![FormName]![FormControl])
This works for the records with fields that are blank.
Code:
=IIf(IsNull([Forms]![FormName]![FormControl]),"",[Forms]![FormName]![FormControl])
This works for the records with fields that have data.
Code:
Like IIf(IsNull([Forms]![FormName]![FormControl]),"*",[Forms]![FormName]![FormControl])
This works for the records with fields that are Null or Blank if i drop the iif function but then i lose the ability to pull criteria data from the form control.
Code:
"" Or Is Null
View 3 Replies
View Related
Oct 23, 2005
I am trying to resolve an issue of being able to use a query from many different forms where the query is dependent on the date selected in the current open form. Right now it calls the function getDate() which works fine. Unfortunatly the function is called before the form is fully loaded and the control I want to pass has no value/doesn't exist yet and I get a
"Runtime error 13 Type-Mismatch"
Here is the function code:
Function getDate() As String
If fIsLoaded("F_SupplierData") Then
getDate = Form_F_SupplierData.txtDate
Else
getDate = "01/01/1901"
End If
End Function
Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function
Is there a way to detect the state of the text field itself (if it is open, closed, dirty)? Or if anyone has a better way to tie a query to multiple forms?
View 5 Replies
View Related
Jul 18, 2013
all using access 2010. I have a date field. I need to write a query to pull out dates with current year only. ex data: 1/1/10, 1/1/11, 2/1/12, 2/1/13. Need to pull all dates with current year which would be 2/1/13. Tried in query criteria of the date field: =Format(Now(),"yyyy") I received data mismatch. this is a date/time field.
View 4 Replies
View Related
Nov 18, 2013
I am struggling trying to execute a function inside a Form_current event to display some stats.
The Function is this:
Code:
Function FlightsByAircraft(Aircraft As Long) As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim str As String
str = "SELECT * FROM tblFlights WHERE AircraftID = " & Aircraft
[Code] ....
The code for the Form_Current event is this:
Private Sub Form_Current()
txtStats1 = FlightsByAircraft(Me.AircraftID)
Very simple. Well, the problem is when I move to a new record, a error message comes up: "Run-time error '94' - Invalid use of Null". It is because the AircraftID is not populated at that time. I tried to insert in the function code something like that:
Code:
If IsNull(Aircraft) then
exit function
else
.... (the DAO.Recordset code)
but it doesn't work.
View 8 Replies
View Related
Aug 22, 2014
I am attaching a picture of what I am talking about as this is going to get confusing...at least it is for me.
I have a Navigation Form that holds 7 tabs that pull reports or data entry forms.
I am trying to get the Preview Selected Record function to pull the UniqueID field from the Data Entry Form and generate a report for printing.
I can search by UniqueID in the data entry form with no problem, it is linked to two subforms with no problem.
Here is the code I have used most successfully:
Code:
DoCmd.OpenReport "rpt1", acViewPreview,, "UniqueID =" & Forms!MainForm!NavigationSubform.Form.UniqueID
This actually works, but every time the print preview is closed, it crashes Access. I have researched this particular issue, and some of the solutions I have read and tried lead to "that method is not allowed or supported" errors or Run-Time 438 errors.
View 9 Replies
View Related
Feb 22, 2005
Is there a function, or an object property, which will return the name of the Sub routine or Function that is currently processing?
View 10 Replies
View Related
Jun 28, 2005
Hey Everyone. I'm a Novice so don't know if what I'm asking is either easy or hard to do. I have a DB for our record label. One table is Incoming Materials, the other is Assigned Materials.
I need a button that when pressed takes all the data from one table and put into the other. Both tables contain the same fields although Assigned Materials has alot more obviously.
Anyone done anything like this before or have any clue how I can do this. Keep in mind that I'm an annoying Novice. Thanks for any help. I promise I won't be a Novice for long
View 5 Replies
View Related
May 18, 2006
Need some feed back here.
Have I pushed Access to the limit? Everything runs great, although I do have some hecups, once in awhile but nothing major.
I'm at 100 megs. I have 40 users with read/write. I have maybe 300 users with read only.
The IT people told me that Access is not design to do this kind of work. I mention that it been running for over 7 years, with very few problems.
Those problems I created myself.
I guess I need some feed back from what you think.
View 3 Replies
View Related
Apr 7, 2015
I have 3 text files, I receive daily, that I need to import into my database. Until we upsized to SQL, we were manipulating the data in Access, and everything was fine.
These three files do not come with a primary key, and we have to insert one row of information into one of the tables. Once we get the flat files, we use our import specifications to set the field types, etc.
Our process works like this:
1. Get the files and import them by spec.
2. Compare one of the import tables (importTable_new) to the current table and write the differences to a third table.
3. Delete out the data from the old tables and copy the new information into them.
This process cannot change due to the way our system is setup. Our data gets filtered prior to us receiving the file, so we have to make sure we always use the most current data from the extracts. We have saved previous data in other tables, so I am not worried about that part.
My problem is this: I am using a DSN-less connection (ODBC) to the SQL server and if I try to run a query that updates the SQL-tables, using a local table, it errors out. There are a myriad of errors that came out of this, I have tried to hunt down what I could and solved a fair amount. However, I continually get:
MS Jet OLEDB 4.0 cannot be used for distributed queries because the provider is used to run in apartment mode.
I have done the steps on the SQL server to remedy this error to no avail (turning on ad hoc reporting, etc).
I have tried OpenRowSet, but that did not work out all due to the continual error from the server.
I tried to use an SSIS and it drops the import specifications on import to SQL from Access.
All I want to do is take three local tables and paste the results in the matching 3 SQL tables in the backend, without deleting the tables (or if I have to delete the tables, to be able to re-create them with the right field types and settings). The tables are identical in field type, name, size, etc.
We are using SQLserver2008(R2) and Access2010.
View 5 Replies
View Related
Aug 27, 2013
What I really need is for when the form opens, it looks at todays date, then matches current user and then goes to that record for today, if no current user there, then will goto new record..
i know, sounds complicated, and probably is really easy, but my heads not with it today, as about to get drunk as its my 40th, and got people ringing and texting and still trying to get this done....
I've included a copy of this database, named Timecards..
View 1 Replies
View Related
Mar 13, 2014
I have created a report that includes 4 subreports. The subreports are displaying survey results from 4 different survey channels. New survey data is added to the tables monthly so the subreports will grow in size. Is there a way to have the subreports automatically resize and push down the subreport below? Currently what is happening is a subreport will grow and the additional data disappears underneath the next subreport. Is there a better way to create a report that displays information from multiple reports that will change in size?
View 1 Replies
View Related
Feb 11, 2015
I am trying to generate standard Avery 2160 address labels. Fonts are small enough to allow for up to 4 print lines none of which quite touch. Players have entered their own names and addresses via a website form, so I we never quite know what is in the fields. If the player has a foreign address, it will all be entered in the address field, whereas US addresses have 1 or 2 lines in the address field, and city, state and zip in their respective fields. Line 1 is set as name, no shrink or grow. Line 2 is set as address, shrink and grow set to yes, and line 3 (text4) is set for city & state & zip, concatenated and trimmed in the query, shrink and grow no. The detail OnPrint event is the following:
Code:
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.Text4.Visible = False
If Len(Text4 & vbNullString) > 1 Then
Me.Text4.Visible = True
End If
End Sub
The problem: Any row containing at least one label with 4 print lines pushes the next entire row of three labels down one line, throwing off the spacing of the labels. If I set line 3's can shrink to yes, then the label following the four-line label never has its text4.visible turned to yes, and the other problem (pushing next row down one line) persists. These labels were originally set up via the labels wizard (Access 2010).
How can I keep it from overflowing from one label to push down the next line? This just shouldn't be this hard!
View 2 Replies
View Related
Jul 22, 2014
I have written a user defined function that calculates the end of the current month. This I named EndOfThisMonth. It works well as a function. Now I would like to use it as date criteria to include in a query. The function is included as such EndOfThisMonth().
The field on which this function is to enter as a criteria is another calculated date function called Due.
When I run this query I get an error message saying Undefined Function 'EndOfThisMonth' in expression.
View 3 Replies
View Related
Aug 15, 2007
Code:INSERT INTO [Status Log] ( Status, Edit_Date, Event, Claim_ID )SELECT [Status Lookup].Status, Now() AS Expr1, "3rd Party Denial" AS Expr3, [Claim Report Info].[Claims Header].Claim_IDFROM [Status Lookup] RIGHT JOIN ([Claim Report Info] LEFT JOIN [Status Log] ON [Claim Report Info].[Claims Header].Claim_ID = [Status Log].Claim_ID) ON [Status Lookup].status = [Status Log].StatusGROUP BY [Status Lookup].Status, Now(), "3rd Party Denial", [Claim Report Info].[Claims Header].Claim_IDHAVING ((([Status Lookup].Status)=[Forms]![claiminformation]![ReportForm]![reportstatus1]) AND (("3rd Party Denial")="![claiminformation]![ReportForm]![txthiddenvalue]") AND (([Claim Report Info].[Claims Header].Claim_ID)=[Forms]![claiminformation]![ReportForm]![Report_ClaimID]));
here is my current query.
i'm trying to append data to a table from my form.
"![claiminformation]![ReportForm]![txthiddenvalue]"
but since it's my value from txthiddenvalue isn't anywhere in my query how do i get this to work?
View 1 Replies
View Related
Feb 28, 2005
Sorry if this has been asked before but I have searched and couldn't find an answer
I have a string that is set on startup (username) and have another form(hidden) that loads on startup this form contains information on what forms and options the user can access. Just having a little trouble using the string to pull the correct record, the information in the string would be from the primary key field on the table.
Thanks
Ryan
View 2 Replies
View Related
Jul 6, 2006
On my first form I have a pull down box and when I select an item and click the add button, the item appears in a locked text box above the pull down box. After I click the submit form button, it goes to another form. On the other form is a similar pull down box and locked text box. So far I got the item selected on the first form to appear in the second form's locked text box.
Again, the second form also has a pull down menu and when I select another item from the pull down box and click the add button on the second form it deletes the first item selected in the first form from the second form's locked text box. The items selected are put in a table. I was wondering if there was some kind of code I can input so the second form's locked text box keeps the first value from the first form and can add additional values when selected through the second form's pull down box. Sorry if this sounds confusing. I really appreciate your help. Thank You.
View 1 Replies
View Related
Jul 4, 2014
Is there a way to pull data into my form so that I can see current stats about my table in the same box as where I'm entering new data?
View 7 Replies
View Related
Sep 23, 2007
I have this basic question (obviously not so basic for me): how to pull out only unique records from two fields.
More details - two fields with names of competitors in a tournament (Winner or Loser) and i need to build a query to have all players names participating in the tournament regardless if they have won or lost in one list.
View 4 Replies
View Related
Jul 22, 2015
I have a query that is pulling a date from a Form. In my Query Criteria, I can put:
Code : >=[Forms]![frmAdhoc].[Date]
or
Code : <=[Forms]![frmAdhoc].[Date]
or
Code : =[Forms]![frmAdhoc].[Date]
And it works fine, but I don't want to hardcode the ">=", "<=" or "="
I would like the user to be able to choose ">=", "<=" or "=", from another field on the Form, so I am trying to code it on the query like this:
Code:
IIf([Forms]![frmAdhoc].[Variable]=">=",>=[Forms]![frmAdhoc].[Date],IIf([Forms]![frmAdhoc].[Variable]="<=",<=[Forms]![frmAdhoc].[Date],IIf([Forms]![frmAdhoc].[Variable]="=",[Forms]![frmAdhoc].[Date])))
But it isn't working for the ">=" or the "<=". It just gives me a blank result.
View 2 Replies
View Related
May 21, 2015
I have a perplexing problem. I'm creating a simple db to enter borrower audit checklist data with the following tables:
Questions -- A list of 17 pre-defined audit questions, with fields QNum and Question
Audits -- One record for each audit (pk AuditKey is an Autonumber), and some borrower fields
AuditQuestions -- Linked to Audits, with pk of AuditKey and Qnum, and a Question and Answer (yes/no) field
The Audits form has the Audits table as its datasource, and an AuditQuestions subform. When I go to a new Audits record, there are initially no subform records attached. When I enter a borrower name, the field AfterUpdate event runs the following code:
Code:
DoCmd.OpenQuery "LoadAuditQuestions"
Me.AuditQuestions.Requery
The SQL for LoadAuditQuestions is
Code:
INSERT INTO AuditQuestions ( AuditKey, QNum, Question )
SELECT [Forms]![Audits]![AuditKey] AS Keyval, Questions.QNum, Questions.Question
FROM Questions
ORDER BY Questions.QNum;
I start out with both Audits and AuditQuestions tables empty. When I run the code by entering a borrower name, I get, "... can't append all the records in the append query ... didn't add 17 records due to key violations". It acts like it's getting a null value from Forms!Audits!Auditkey, but if I select the Debug option and check the value from the Immediate pane, it shows a valid number. Also, if I run the query manually with the form open, it loads the questions correctly.
The first Audits record is loaded with questions in the subform so you can see the desired results. To see the problem, go to a new record, enter a name, and hit tab. Another piece to the puzzle is, if you do this on an existing record, it works fine: Click No in response to the error message that appears, then click End on the Debug message. Go to a different audit record, then come back to the one you just created. Change the name, and it works correctly. It's as if it doesn't know what the AuditKey is the 1st time, but if you check it in debugger, it is loaded. In fact, I put in code in the AfterUpdate event to plug the LoanNumber field with the Forms!Audits!Auditkey value, and it worked, but the subsequent query still failed.
View 3 Replies
View Related
Mar 24, 2005
I'm a complete newbie at Access. A friend (she's the Secretary of our small town's Service District Board of Trustees) asked me to develop a database for keeping records of property owners here, to facilitate such things as sending the yearly fee letter, tracking mailing addresses and property addresses, whether the fee is paid, etc.
I figured out most of it by "taking apart" a database she uses for another organization. It wasn't easy, but it's all working EXCEPT the thing she uses most: a last name input form (a combo box entry field with a command button) which is supposed to bring up the appropriate "Edit Existing Owner" form by the last name entered (or give an error message if there's no owner by that name, of course). The form works - but simply brings up the last-entered record.
I've looked at the setup in the other database, I see that when I create this form relationship, the VB code is nowhere close to what's in the other database. Trying to use the code from the other database is ineffective, even though the relationship is exactly the same. I'd be happy to have someone look at the forms etc. but the database compressed to a .rar file is 818k which is pretty big - and I'm not sure how to provide just the parts which aren't working.
I can upload the database to webspace and direct someone there if they'd be willing to take a look....
Thanks for any help!
View 14 Replies
View Related
Dec 16, 2004
I have a report with a calculated field. This calculated field needs to pull the value or total from a field in another report. I think the formula is :
=([AssmntC].Reports!totalreqamnt4)
but I'm getting ?Name as the result.
The report is AssmntB where I need to have the value copied.
The original report is AssmntC and the field is totalreqamnt4 where the value is originally calculated.
totalreqmant4 is also a calculated field which sums fields from a query.
Help with the formula? please?
View 2 Replies
View Related
Jun 15, 2006
I need to pull data from a master project list to auto update other forms. When someone enters a project number I need it to pull the data for that project into another form so they dont need to keep typing details in. The other forms are trackers for our processes to complete the projects.
Let me know what you think...would a subform pull the info automatically somehow?
View 3 Replies
View Related
Apr 17, 2015
how to design a form that can pull multiple invoices data related to the same purchase order number?
View 14 Replies
View Related