Find Newest Record, Close Word & Not In List
Jul 5, 2005
I've almost completed the DB I'm working on, but still have a few loose ends to tie up that I can't seem to figure out. I've spent many hours already on this forum searching for solutions, and have tried a few different things, but I still can't work out these bugs.
First, I need my form to open with the latest records filtered first, so that the most recently added records will be easiest to find and edit. I'm not sure how exactly to do this. I've tried a run query when the form is opened, but I still need all the records displayed or accessible. The form is called frmDenial, and I would like it to be looking in the DateLogged field of the form. Any suggestions?
Second, I have command buttons that will export data in the fields to MSWord Templates via bookmarks. The button runs well by opening the document, inserting the data, and printing. I have also tried several different code syntax to close word once it is done, but it is still staying open after printing. Here is a sample of the code:
________________________________________
Private Sub Print_Letter_Click()
Dim objWord As Word.Application
'Start Microsoft Word 2000.
Set objWord = CreateObject("Word.Application")
With objWord
'Make the application visible.
.Visible = False
'Open the document.
.Documents.Open ("G:PharmacyPrior Auth Docs and DataRevised Pharmacy Denial ProcessesKAN Not Nec or Benefit2.dot")
'Move to each bookmark and insert text from the form.
.ActiveDocument.Bookmarks("bmkFirstName").Select
.Selection.Text = (CStr(Forms!frmDenial!MBRFirst))
.ActiveDocument.Bookmarks("bmkLastName").Select
.Selection.Text = (CStr(Forms!frmDenial!MBRLast))
.ActiveDocument.Bookmarks("bmkHRN").Select
.Selection.Text = (CStr(Forms!frmDenial!MemberNumber))
.ActiveDocument.Bookmarks("bmkAddress1").Select
.Selection.Text = (CStr(Forms!frmDenial!MBRAddress1))
End With
Print_Letter_Click_Err:
'If a field on the form is empty, remove the bookmark text, and
'continue.
If Err.Number = 94 Then
objWord.Selection.Text = ""
Resume Next
End If
objWord.Application.Options.PrintBackground = False
objWord.Application.ActiveDocument.PrintOut
objWord.Application.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
'Quit Microsoft Word and release the object variable.
objWord.Quit
Set objWord = Nothing
Exit Sub
End Sub
_______________________________________
Finally, I have two cascading combo boxes set up that will auto pop related fields based on the selection made. But, if an item is not in the list, I would like the user to add it to the linked table to appear in the list. I also have this working well, with a pop up asking the user if they want to make the addition, type in the new item, and add to the list without requiring the user to refresh or exit then re-enter the form. But it will only add the item name, and not the item description (another field in the form and another column in the table). How can I modify the code to prompt the user to enter these other details? I can link it to a pop up sub form to enter the data, but if possible, would rather the boxes pop up to have the user type in the data. Here is the code I have so far in the NotInList Event...
__________________________________________
Private Sub DrugName_NotInList(NewData As String, Response As Integer)
Dim DB As DAO.Database
Dim rs As DAO.Recordset
Dim strMsg As String
strMsg = "'" & NewData & "' is not an available Drug" & vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add the new Drug to the current Database?"
strMsg = strMsg & vbCrLf & vbCrLf & "Click Yes to add or No to re-type it."
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new model?") = vbNo Then
Response = acDataErrContinue
Else
Set DB = CurrentDb
Set rs = DB.OpenRecordset("tblDrug", dbOpenDynaset)
On Error Resume Next
rs.AddNew
rs!Drug = NewData
rs.Update
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If
rs.Close
Set rs = Nothing
Set DB = Nothing
End If
End Sub
______________________________________________
The two other colums in the tblDrug that I need the user to be prompted to fill are Denial Reason (column 3) and Alternative (column 4). What would be the best way to accomplish this?
I would really appreciate any help or suggestions with any of these problems. Thank you so much! :o
View Replies
ADVERTISEMENT
Aug 17, 2007
Hello,
I have looked for ages for a solution to this and have not yet found one to suit me so here I am.
I am creating an Access 97 db in which I have a form (section1) which shows its records in datasheet format(results from a query). On this form is a button which opens another form (fileViewNewSec1) where the user can input the data for a new record. In the closeEvent() part of this form I have put:
=[Forms]![section1].[Requery]
This successfully refreshes the form and the new record can be found. However, there are many records in this database and it would be nice if once the form (section1) has been refreshed that it would focus on the newly created record. I am not sure if anyone can help me with this.
The records are sorted by "fileRef" and therefore the newly created record is not placed at the bottom of the records. They do however have an auto number primary key, I am not sure this will be useful but they you go.
Cheers
MArk
View 3 Replies
View Related
Apr 24, 2013
I have a Find Duplicates query that I created with the Query Wizard.
IF I run the query and find duplicates, I can close the resultant datasheet with the close button.
IF I run the query and find duplicates and delete them, I can close the resultant datasheet with the close button.
IF I run the query after I have found and deleted duplicates and closed the window, I can close the resultant datasheet (with no records) with the close button.
BUT IF I run the query when there are no duplicates, it opens the datasheet with no records, but you can't close it with the close button. You have to exit the database completely.
I don't know SQL or VB. Have to do this in Access.
I thought about creating an If statement in a macro, but am not sure of the syntax, but this would be the basic statement I would make:
IF Find Duplicates query returns no records,
THEN Cancel Event.
End IF
View 2 Replies
View Related
May 23, 2005
A customer's name is SZEE. Seek him through the SName textbox with Find, and Access can't find him. (Same in the table.) Seek him with a wildcard Sz* and there he is.
I've tried it on another machine - also with Access2k - and it's the same.
Is it an Access quirk? Is there an answer? (The client asks why. Be good to be able to say.) Cheers.
View 3 Replies
View Related
Feb 15, 2007
Can anyone help me in creating a field from a query which will pull the first word only from a specific field.
Thanks.
View 2 Replies
View Related
Jul 31, 2007
Hello,
I asking to see if it is possible to run a query on a memo field. For an example I want to pull all records where the memo field contains the word "Test".
Is this possible?
Thanks!
Fen
View 1 Replies
View Related
Mar 18, 2015
I need to find whether a memo field contains a specific word. I know how to find whether it contains a specific string.
Let's say I am looking for the word "run." I would not want a positive result when searching "I don't like gerunds," but I WOULD want to find the records with "I know how to 'run' a search."
So I am looking for WORDS, not matching strings.
I am perfectly willing to use a user-defined function, to put involved processing into the query, such as
Code:
...
WHERE FieldHasWord("run", memoField) = True
AND ...
View 3 Replies
View Related
Sep 18, 2013
I have 5 textboxes and a multiline textbox in a form in my Access Database. I am going to type several keywords in those textboxes and I am going to type an article in the multiline textbox.
What I need to do is I want to calculate the keyword density in the article. I can do that if i know how to search the whole text in the article and count the specific word. And I want a function to count all the words in the article too.
View 1 Replies
View Related
Oct 11, 2006
Hi All,
I have attached a DB that I am trying to create for my small business. Every month we have renewals of the client’s yearly contracts. I have created a form called frmRenewells, on this form you need to select a month and a year (please choose October 2006) this then runs query qryRenewell. The query then opens form frmRenewellSheet with the results. This works fine, but I really need the following to happen:
Open form frmRenewells and enter month & year, on clicking the enter button it launches a word template I have created and automatically pulls all the fields required into the word document. I can then press print and it will print a document for each client in the query.
I am unable to go into word and just open the query as it has * or wildcards in it. Therefore word will not allow me to select the query.
I have attached the Word doc as well
Thanks in advance,
Danian
View 1 Replies
View Related
Sep 1, 2014
I have a query in Access and a word document that opens up the query. Currently the query contains every record in the database. If I alter the query in Access to select a certain set of records (based on dates) when Word opens the recipient list is empty. Checking for errors it says there were no records or no data records matched query options.
How can I get Word to open and use the modified query?
View 3 Replies
View Related
Jun 10, 2005
hello again guys
i got another question...
i have a "quit" button on my form that closes access. my problem is that if there is something selected from my list box and something entered into my textbox, it will add the record when i click quit. what can i do to make it NOT add the record. i've searched on google all day and i've been trudging through a bunch of forums and still can't find anything. i did see something about the dirty property, but i can't seem to figure out how i can use that to my advantage. please help!!!
thanks a bunch
*j
View 4 Replies
View Related
Feb 1, 2008
I've been searching the forum for an answer and see that there are a lot of knowledgable people out there but didn't find an answer to my problem so I'm hoping someone can help.
I have a table that has PartNo, Unit_Price, Updated_Date. It is filled with every purchase we have made for the past two years, so there are multiple records for the same part numbers with different prices and different dates. I'm looking to pull the most recent dated record for each part number. For example:
PartNo Unit_Price Updated_Date
123 7.89 08/12/07
123 7.91 10/15/07
123 8.02 1/10/08
I would like it to return the bottom record only (and do this for each of the hundereds of part numbers we have) so I end up with a table that looks like...
123 8.02 1/10/08
456 1.52 1/22/08
789 10.59 8/02/06
and so on... :D
Any ideas:confused:
View 7 Replies
View Related
Jan 23, 2006
Hi,
on a form with several subforms i have ran into some trouble. I have the subforms use code to determine if a scrollbar is needed. As a recordselector I use a listbox on the main form.
When i close the mainform, it sometimes makes a popup box appear saying that there is no current record.
Sofar I have determined the following :
- Removing the code from the form, removes the error.
- The code is only executed when selected records in the listbox have related record(s)
- The error only occurs when the code is executed at least once and the last selected record has no related record(s)
I dont know if altering the code would have any success, cause it won't run anyway when I select the last record (with no related records).
I guess moving the code to another section would be better, but I've tried other options like 'on focus' etc, but could not find one that responded.
HELP PLZ :)
Private Sub Form_Current()
On Error GoTo Error
'kijken of verticale scrollbar nodig is
maxRegels = 14
Dim rstCount As DAO.Recordset
Set rstCount = Me.Recordset
If rstCount.RecordCount > maxRegels Then
Me.Form.ScrollBars = 2
Else
Me.Form.ScrollBars = 0
End If
Error:
If Err.Number <> "0" Then
Else
MsgBox Err.Number & " " & Err.Description
End If
Exit Sub
End Sub
ps. I've tried to catch err.Number = "3021" in the Error: section, but without success
View 5 Replies
View Related
Aug 4, 2015
I'm trying to find the Before Update event in the event builder and I cant see it anywhere.
I've seen a few different ways of achieving the same thing but so far nothings worked.
If a user adds wrong information and choses to close the form then it always saves the data. I only want it saved if the user choses to save it.
The close button I have has saving turned off but it seems the record has already been updated by that point.
The before update is in form properties, I have found it now. But I cant set the parameter 'Cancel' to True.
If I look at the forms code this is there,
Option Compare Database
Private Sub Form_BeforeUpdate(Cancel As Integer)
End Sub
View 10 Replies
View Related
Jun 23, 2005
I have a crosstab query that I ONLY need the newest date from the table I'm pulling from reguardless of what it is for. Here is what I have:
TRANSFORM Max([Cust Count].[Active Customers]) AS [MaxOfActive Customers]
SELECT [Cust Count].Node, Sum([Cust Count].[Active Customers]) AS [Total Of Active Customers]
FROM [Cust Count]
WHERE ((([Cust Count].Services) In ("core","data","telephone")) AND (([Cust Count].ASC)="uh") AND (([Cust Count].Date)=#6/12/2005#))
GROUP BY [Cust Count].Node, [Cust Count].Date
ORDER BY [Cust Count].Node
PIVOT [Cust Count].Services;
I know this is only setup to get items from 6/12/05 but more will be added to the table and I only want the new info for this query. Thank you.
View 11 Replies
View Related
Mar 13, 2006
I am a relatively new to some of the more advanced features of Access. Here is my problem:
I have a table that will be linked to a graph. Each record is for a particular date. There can be multiple dates within a month, but for each month I only want to display the most recent date within a given month. In other words, the graph will only display data from the last record in a given month.
My idea was to somehow flag the records that are the newest date within a month. However, I would also be open to running an append query to simply delete these records as the table is updated (though I would rather preserve the records and stick with the "flagging" option).
Any help would be much appreciated.
View 1 Replies
View Related
Feb 28, 2014
I have a form frmAddNewProject that is a Data Entry form.When you click Add Project on the form, it creates folders and copies files to a location and also creates new record(s) in the ProjectT table with appropriate information.Here is my code:
Code:
Private Sub cmdAdd_Click()
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim FolderPath As String
Dim strType As String
Dim strYear As String
Dim strGPN As String
[code]....
Everything works fine till here. Now I would like to close the form but closing it gives me an additional empty record.
Code:
Dim ctl As Control
On Error Resume Next
For Each ctl In Me.Controls
ctl = ctl.DefaultValue
Next
Set ctl = Nothing
to remove all values, but then it just adds an empty record.Is there a way to close that form without removing my legitimate new records and without adding empty ones?
View 4 Replies
View Related
Jun 3, 2015
I have a form I would like to close without saving the record using a button. here is the code I have but it closes the form and it also writes the record to the table.
Code:
Private Sub ClosewoSave_Click()
Cancel = True
Me.Undo
DoCmd.close
DoCmd.OpenForm "frmMenu"
End Sub
I found in a thread that Cancel = True would not write the record.
View 4 Replies
View Related
Nov 24, 2014
Access 2010 - I would like to close particular field and duplicate record.
Duplicate record is working file. I do not know to close the particular field.
Option Compare Database
Private Sub cmdDuplicate_Click()
On Error GoTo Err_cmdDuplicate_Click
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdCopy
[Code] ....
View 2 Replies
View Related
May 16, 2013
I have a simple EXIT command button that runs these macro actions: save record, close form. I also have a SAVE command button that runs this macro action: save record. If a user closes the form without clicking either the EXIT or SAVE command buttons, will the record changes be saved in the datasource table.
I have found from testing that the data is always saved even if the user does not click the EXIT or SAVE buttons, but I wanted to be absolutely certain. Is this correct ?
View 1 Replies
View Related
Feb 6, 2014
I have a database which has a main form and subform built in linked by parent/child customerid, what i would like to do is search all the subform records from the whole DB and return its parent record on the main form?
Can this be done? because if i use find it will only search the filtered form i have onload of the form?
My onload event is based on fosusername()
View 3 Replies
View Related
Jul 28, 2015
I have Query which has dates in multiple columns. I need to know if there is a formula that will allow me to display the oldest date and the newest date?
Below is the output of my Query in Excel. I need the output to have two additional columns: Beginning Date and End Date. Based on the example below, I would need the beginning date to show 6/21 and the end date column to show 6/23 so when I export to excel, it shows these two dates. In Excel, there is a min/max formula that can do this but it looks like the min/max in Access only displays the min/max data? Unfortunately, creating this formula is not an option after the fact. Secondly, I need the word "DIRECTION" to show in it's own separate column in the in the query. I don't know if I can do this without adding another table to the Query or if I need can just add a column in design view and put something in the criteria that will do this.
I have included an example of my current output and what I need the output to read.
Current Output
Sunday
In
Out
Monday
In
Out
Tuesday
In
Out
[code]....
View 2 Replies
View Related
Dec 16, 2007
Hi there,
This may mean stupid question to you but I find that some of the events or types in the properties which give me 'no meaning' at all.
For example, has module on form, on retreat on report. THIS IS ONLY A sample, my list would be endless.
Thanks in advance
View 3 Replies
View Related
Oct 11, 2013
I have no experience with Access Modules which I think I need to find all the queries that reference a field, in this example: LAWSON_LHSEMPDEMO.R_STATUS
I would like for the module to list all the queries for me that reference this table and field of "LAWSON_LHSEMPDEMO.R_STATUS"
Is there an easy way to do this?
View 4 Replies
View Related
Aug 29, 2014
I need a Query that grabs the lastest "newest" data from the 5 tag.table tags generated from the query below and Display them in a result,
SELECT FloatTable.DateAndTime, FloatTable.TagIndex AS FloatTable_TagIndex, FloatTable.Val, TagTable.TagName, TagTable.TagIndex AS TagTable_TagIndex
FROM FloatTable INNER JOIN TagTable ON FloatTable.[TagIndex] = TagTable.[TagIndex];
View 1 Replies
View Related
Dec 17, 2013
I have a combobox (cbo_FileNames) that is unbound and gets fed on activate from a folder
Code:
Set SourceFolder = FSO.GetFolder("c:GundogManagerBackUp")
My problem is that the file names are as follows:
GundogManagerBackUp 02_12_13.xls
GundogManagerBackUp 03_12_13.xls
GundogManagerBackUp 07_08_13.xls
GundogManagerBackUp 16_11_13.xls
GundogManagerBackUp 17_12_13.xls
As you can see it consists of the name and a date of the backup. When it populates the combobox I want it to go in date order I newest to oldest. At the moment its going of the first number.
View 9 Replies
View Related