Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435

    What type of code are you looking for?

    If you are looking for a specific piece of code it can be difficult to find an example by searching through the posts. So use this thread to ask for examples.



    KISS - Keep It Short & Simple

    Check to see if is has not been requested and provided already

  2. #2
    burt is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    2
    XP, Access 2000. I want to provide user with a button on a form which will replace all FLAG fields containing an "L" with an "R". Am almost there with macros, but can't make the macro quit neatly. Thanks.

  3. #3
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Table and field names are for brevity only. Use your real names.



    Code:
     
    Private Sub CommandButton_Click()
     
    'Surpress Access action alerts 
    DoCmd.SetWarnings False
    'Run update sql
    DoCmd.RunSQL "Update [YourTableName] Set [YourField]= 'L' Where [YourField]='R'"
    'Switch alerts back on
    DoCmd.SetWarnings True
     
    End Sub


    David

  4. #4
    burt is offline Novice
    Windows XP Access 2000
    Join Date
    Sep 2009
    Posts
    2

    Thanks - Problem solved

    Thanks for your prompt response. Works just like I wanted.

  5. #5
    HansSkyboy is offline Novice
    Windows XP Access 2007
    Join Date
    Nov 2009
    Posts
    1

    Code to hide Ribbon and QAT

    I am trying to use the following in the autoexec macro to hide the ribbon and QAT, but it does not work for me. I do not know the full way that it has to be put into a module as code. I am new to VBA.

    Public Function DisableRibbon()
    DoCmd.ShowToolbar "Ribbon", acToolbarNo
    End Function

    Access 2007, Windows xp

  6. #6
    AHopko is offline Novice
    Windows XP Access 2003
    Join Date
    Dec 2009
    Posts
    1
    I'm receiving data in a csv format from online request forms that are built on our website. Most fields break out easily into their respective columns, however one field is basically all the collective MetaData from each of the custom qualifier questions we ask in our form. An example of how the metadata looks is below:

    <grp8_dealer><![CDATA[86]]></grp8_dealer><grp8_how_hear><![CDATA[Search Engine,Previous Experience,Referral]]></grp8_how_hear><grp8_how_hear_other><![CDATA[]]></grp8_how_hear_other><grp8_also_interested><![CDATA[PondAndLakeManagementCD,SpecificationManual,Specif icationManualCD,Site Evaluation]]></grp8_also_interested><grp8_additional_comments><![CDATA[]]></grp8_additional_comments><grp8_interested_in><![CDATA[AeratingFountains,LargeAeratingFountains,GiantFoun tains,SmallPondSystems,FountainGloLighting,LakeDye]]></grp8_interested_in><grp8_pondlake_experiences><![CDATA[FoulOdors,AlgaeBlooms,FishKills]]></grp8_pondlake_experiences><grp8_pondlake_experienc es_other><![CDATA[]]></grp8_pondlake_experiences_other><grp8_pond_used_fo r><![CDATA[Recreation,Stormwater]]></grp8_pond_used_for><grp8_pond_used_for_other><![CDATA[]]></grp8_pond_used_for_other><grp8_purchase_time><![CDATA[]]></grp8_purchase_time><grp8_market_associated_with><![CDATA[Residential,Commercial,Municipal]]></grp8_market_associated_with><grp8_market_associate d_with_other><![CDATA[]]></grp8_market_associated_with_other>

    I need to know how I can get each of the <grp8_*> values to be established as the column headings and the <!CDATA[*]> values associated with them to appear as the field values below. (if nothing is answered/selected there is still a <grp8_*> heading, just no <!CDATA[*]> value assisnged to it.)

    Ideally once the values in the MetaData column are broken out into their own columns, I need them to remain associated to their respective customer record (ie name, company, etc.)

    Any suggestions, guidance and/or assistance is GREATLY appreciated.

    Thanks!

  7. #7
    caddadd is offline Novice
    Windows XP Access 2003
    Join Date
    Jan 2010
    Posts
    3

    Question User Custom Reports

    I am looking for a way to allow a user to define their own custom reports on the fly from the existing database tables and queries.

  8. #8
    Join Date
    Jun 2009
    Location
    Vietnam
    Posts
    4
    Hi all,
    Sorry, my English isnt good, it makes me confused .
    How can I get all IP address on LAN using VBA?
    Thank you!

  9. #9
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931

    IP Address

    Option Explicit

    Private Const IP_SUCCESS As Long = 0
    Private Const WS_VERSION_REQD As Long = &H101
    Private Const MIN_SOCKETS_REQD As Long = 1
    Private Const SOCKET_ERROR As Long = -1
    Private Const INADDR_NONE As Long = &HFFFFFFFF
    Private Const MAX_WSADescription As Long = 256
    Private Const MAX_WSASYSStatus As Long = 128
    Private Type WSADATA
    wVersion As Integer
    wHighVersion As Integer
    szDescription(0 To MAX_WSADescription) As Byte
    szSystemStatus(0 To MAX_WSASYSStatus) As Byte
    wMaxSockets As Long
    wMaxUDPDG As Long
    dwVendorInfo As Long
    End Type
    Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal hostname As String) As Long
    Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (xDest As Any, xSource As Any, ByVal nbytes As Long)
    Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Long, lpWSADATA As WSADATA) As Long
    Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
    Private Declare Function inet_addr Lib "WSOCK32.DLL" (ByVal s As String) As Long
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal Buffer As String, Size As Long) As Long

    Sub TestingFunction()
    If SocketsInitialize() Then
    MsgBox "IP address of " & GetPcName & " is: " & GetIPFromHostName(GetPcName)
    End If
    SocketsCleanup
    End Sub

    Public Function GetIPFromHostName(ByVal sHostName As String) As String
    'converts a host name to an IP address.
    Dim nbytes As Long
    Dim ptrHosent As Long 'address of hostent structure
    Dim ptrName As Long 'address of name pointer
    Dim ptrAddress As Long 'address of address pointer
    Dim ptrIPAddress As Long
    Dim sAddress As String
    sAddress = Space$(4)
    ptrHosent = gethostbyname(sHostName & vbNullChar)
    If ptrHosent <> 0 Then
    ptrName = ptrHosent
    ptrAddress = ptrHosent + 12
    'get the IP address
    CopyMemory ptrName, ByVal ptrName, 4
    CopyMemory ptrAddress, ByVal ptrAddress, 4
    CopyMemory ptrIPAddress, ByVal ptrAddress, 4
    CopyMemory ByVal sAddress, ByVal ptrIPAddress, 4
    GetIPFromHostName = IPToText(sAddress)
    End If
    End Function


    Private Function IPToText(ByVal IPAddress As String) As String
    IPToText = CStr(Asc(IPAddress)) & "." & _
    CStr(Asc(Mid$(IPAddress, 2, 1))) & "." & _
    CStr(Asc(Mid$(IPAddress, 3, 1))) & "." & _
    CStr(Asc(Mid$(IPAddress, 4, 1)))
    End Function


    Public Sub SocketsCleanup()
    If WSACleanup() <> 0 Then
    MsgBox "Windows Sockets error occurred in Cleanup.", vbExclamation
    End If
    End Sub


    Public Function SocketsInitialize() As Boolean
    Dim WSAD As WSADATA
    SocketsInitialize = WSAStartup(WS_VERSION_REQD, WSAD) = IP_SUCCESS
    End Function


    Public Function GetPcName() As String
    Dim strBuf As String * 16, strPcName As String, lngPc As Long
    lngPc = GetComputerName(strBuf, Len(strBuf))
    If lngPc <> 0 Then
    strPcName = Left(strBuf, InStr(strBuf, vbNullChar) - 1)
    GetPcName = strPcName
    Else
    GetPcName = vbNullString
    End If
    End Function


    I forund this on the web see if it serves your purpose.

  10. #10
    cdh is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2010
    Posts
    15

    calculate totals hours worked across midnight

    I am trying to build an expression that calculates the total hours worked that may or may not cross over midnight. I am using 2007 with colums named Start Date, End Date, Start Time, End Time, and Totoal Hours. I need this to work in both forms and reports. Can someone please help me?

  11. #11
    Yance is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    22
    Hi.. i need to make my access application can't close by using end process/task in windows task manager. But i don't want to disable the windows task manager. I guess i must set the process priority of my application to high level or real time. Any one can know how to do that using vba code?

  12. #12
    BSL2112 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2010
    Posts
    1

    Opening 1 Table, adding records to a second

    Could someone post the best way to open 2 tables in a module? I have one table that has two fields Project and Part (I am ignoring the AutoKey). Ex:

    Project 1, Part A
    Project 1, Part B
    Project 2, Part A
    Project 2, Part C
    Project 2, Part D

    I want the to write in VBA a way to combine the above and create a new record for each Project. Ex.

    Project 1, Part A Part B
    Project 2, Part A, Part C, Part D

    I feel comfortable writing the VBA code in getting the resultant, but I am having trouble getting started with opening the tables required. I started with:

    Dim dbs As Database
    Dim dbsNEW As Database
    Dim rst As Recordset
    Dim rstNEW As Recordset
    Set dbs = CurrentDb()
    Set dbsNEW = EndDB()
    Set rst = dbs.OpenRecordset(StrSQL, dbDynaset)
    Set rstNEW = dbs.OpenRecordset(StrSQL, dbDynaset)


    I error out at the line in Bold. If someone could point me in the right direction, I would appreciate it.

  13. #13
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Hi all. I'm looking for a bit of code that will make a copy of the final workflow table (tableTemp) name it as something entered in a textbox on a form, then move it into one of the "favorites" folders (finalCampaigns) in access 2003.

    Please and thanks.

  14. #14
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by TheShabz View Post
    Hi all. I'm looking for a bit of code that will make a copy of the final workflow table (tableTemp) name it as something entered in a textbox on a form, then move it into one of the "favorites" folders (finalCampaigns) in access 2003.

    Please and thanks.
    the copy is simply Shabz. This will get you to the point where you have to move the new table:
    Code:
        DoCmd.CopyObject , Forms("myform").Controls("textbox"), acTable, "table"
        RefreshDatabaseWindow
    Good luck finding vb on manipulating the db window!

  15. #15
    TheShabz is offline Court Jester
    Windows XP Access 2003
    Join Date
    Feb 2010
    Posts
    1,368
    Thanks. Yea that was the easy part, I know =P. The moving a table to another folder is the real snag for me.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM
  2. Replies: 4
    Last Post: 05-16-2009, 09:17 PM
  3. Replies: 0
    Last Post: 02-27-2009, 01:27 PM
  4. fields of type text
    By ashiers in forum Forms
    Replies: 0
    Last Post: 11-28-2008, 10:52 AM
  5. Number data type
    By BernardKane in forum Access
    Replies: 1
    Last Post: 11-11-2006, 08:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums