Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB 6.0 >>> VB.NET / August 2005

Tip: Looking for answers? Try searching our database.

Access VBA Public Function to VB.NET or VBScript?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SusanV - 19 Aug 2005 16:57 GMT
Hi all,

I have the below code as a public function in Access 2000 .This is the
*only* thing this particular mdb does - autoexec macro calls this function
and at the end of the code Access exits. Just a quick conversion utility,
really. Now I'm told some users do not have access installed so the powers
that be would like to know how difficult it would be to bring this into a
self-contained executable.
The function references one stored query and one table (which is deleted at
start and then recreated) so I don't think there would be a lot to "bring
into" the code but don't know how to go about even starting such a task. I
have Visual Studio .Net 2002 for a dev invironment outside of Access.

Any suggestions or links would be welcome!

TIA,
Susan

Function Create_Pivot()

   MsgBox "This utility will take existing Maintenance Lists " & vbCrLf &
"(Excel file format please!)" _
   & vbCrLf & "from MML Export and convert to Pivot table." & vbCrLf & "To
be used in Generic Plan Development."

   Dim strFile As String
   Dim strFilter As String
   Dim tblName As String
   Dim db As DAO.Database
   Dim fldNew As DAO.Field
   Dim tbl As DAO.TableDef

   strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.xls)", "*.xls")
   strFile = ahtCommonFileOpenSave(Filter:=strFilter, OpenFile:=True,
DialogTitle:="Select import file")
   If strFile = "" Then Exit Function

   DoCmd.DeleteObject acTable, "tblTemp"

   DoCmd.TransferSpreadsheet acImport, , "tblTemp", strFile, True
   Set db = CurrentDb()
   Set tbl = db.TableDefs("tblTemp")
   Set fldNew = tbl.CreateField("Freq", dbText, 50)
   tbl.Fields.Append fldNew

   Dim sql As String
   DoCmd.SetWarnings False
   sql = "UPDATE tblTemp SET units = " & "'" & "Y" & "'" & _
       " WHERE tblTemp.units =" & "'" & "Year" & "'"
   DoCmd.RunSQL sql

   sql = "UPDATE tblTemp SET units = " & "'" & "M" & "'" & _
       " WHERE units =" & "'" & "Month" & "'"
   DoCmd.RunSQL sql
   sql = "UPDATE tblTemp SET units = " & "'" & "W" & "'" & _
       " WHERE units = " & "'" & "Week" & "'"
   DoCmd.RunSQL sql
   sql = "UPDATE tblTemp SET units = " & "'" & "HR" & "'" & _
       " WHERE units = " & "'" & "Running Hour" & "'"
   DoCmd.RunSQL sql
   sql = "UPDATE tblTemp SET Freq = units & interval"
   DoCmd.RunSQL sql
   DoCmd.SetWarnings True

   MsgBox "Please select filename and location to save to!"
   DoCmd.OutputTo acOutputQuery, "qryXtab_tblTemp", acFormatXLS, , True

   DoCmd.Quit
End Function
Ken Tucker [MVP] - 30 Aug 2005 00:52 GMT
Hi,

           Maybe this will help.

http://www.windowsformsdatagridhelp.com/default.aspx?ID=28f49f7c-ec40-4472-9b28-
2b9e762316ab


Ken
-------------------
> Hi all,
>
[quoted text clipped - 66 lines]
>    DoCmd.Quit
> End Function

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.