Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Knowledge Base > Code Repository

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 08-18-2009, 02:14 AM
dcrake's Avatar
dcrake dcrake is offline Windows XP Access 2003 (version 11.0)
Expert
 
Join Date: Aug 2009
Posts: 438
Blog Entries: 1
dcrake is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 09-21-2009, 01:19 PM
burt burt is offline Windows XP Access 2000 (version 9.0)
Novice
 
Join Date: Sep 2009
Posts: 2
burt is on a distinguished road
Default

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.
Reply With Quote
  #3  
Old 09-22-2009, 03:03 AM
dcrake's Avatar
dcrake dcrake is offline Windows XP Access 2003 (version 11.0)
Expert
 
Join Date: Aug 2009
Posts: 438
Blog Entries: 1
dcrake is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 09-24-2009, 02:33 PM
burt burt is offline Windows XP Access 2000 (version 9.0)
Novice
 
Join Date: Sep 2009
Posts: 2
burt is on a distinguished road
Default Thanks - Problem solved

Thanks for your prompt response. Works just like I wanted.
Reply With Quote
  #5  
Old 11-04-2009, 05:01 PM
HansSkyboy HansSkyboy is offline Windows XP Access 2007 (version 12.0)
Novice
 
Join Date: Nov 2009
Posts: 1
HansSkyboy is on a distinguished road
Default 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
Reply With Quote
  #6  
Old 12-30-2009, 07:47 AM
AHopko AHopko is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Dec 2009
Posts: 1
AHopko is on a distinguished road
Default

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!
Reply With Quote
  #7  
Old 01-27-2010, 10:48 AM
caddadd caddadd is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jan 2010
Posts: 3
caddadd is on a distinguished road
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.
Reply With Quote
  #8  
Old 01-27-2010, 04:56 PM
hiền muội's Avatar
hiền muội hiền muội is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Jun 2009
Location: Vietnam
Posts: 4
hiền muội is on a distinguished road
Send a message via Yahoo to hiền muội
Default

Hi all,
Sorry, my English isnt good, it makes me confused .
How can I get all IP address on LAN using VBA?
Thank you!
Reply With Quote
  #9  
Old 02-12-2010, 11:59 PM
maximus's Avatar
maximus maximus is offline Windows 7 Access 2010 (version 14.0)
Wizard
 
Join Date: Aug 2009
Location: India
Posts: 802
Blog Entries: 1
maximus is on a distinguished road
Default 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.
Reply With Quote
  #10  
Old 05-20-2010, 10:11 PM
cdh cdh is offline Windows Vista Access 2007 (version 12.0)
Novice
 
Join Date: May 2010
Posts: 13
cdh is on a distinguished road
Default 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?
Reply With Quote
  #11  
Old 06-04-2010, 04:20 PM
Yance Yance is offline Windows XP Access 2003 (version 11.0)
Novice
 
Join Date: Aug 2009
Posts: 13
Yance is on a distinguished road
Default

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?
Reply With Quote
  #12  
Old 06-25-2010, 12:29 PM
BSL2112 BSL2112 is offline Windows Vista Access 2007 (version 12.0)
Novice
 
Join Date: Jun 2010
Posts: 1
BSL2112 is on a distinguished road
Default 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.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Type Mismatch - HELP! jgelpi Programming 3 07-17-2009 01:53 PM
Same code, different form, one good, other type mismatch Helen Programming 4 05-16-2009 07:17 PM
Type into field that is a Combo Box on the fly Najani12 Access 0 02-27-2009 10:27 AM
fields of type text ashiers Forms 0 11-28-2008 07:52 AM
Number data type BernardKane Access 1 11-11-2006 05:19 PM


All times are GMT -8. The time now is 03:04 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.