S
Savvoulidis Iordanis
Access 2000 SP8, Jet40, Windows 2000 Pro SP3
Hi there. Another problem I run into, has to do with the DoCmd.RunCommand
acCmdSaveRecord, after calling an API function.
I have a form that holds the properties of my report fields, in order to set
them at runtime. One of the properties is the color (fore, back, border),
and the fields that are used for that, are : i_fore_color, i_back_color and
i_border_color, with a little button next to them that calls the following
code (only for the 1st button, the others are the same)
It seems that after calling the APIColorDialog() function, the
DoCmd.RunCommand acCmdSaveRecord, does not work.
What is going wrong?
'-------------------------------------------------------------
' ---- Button to open the color dialog ----
'-------------------------------------------------------------
Private Sub cb_fore_color_Click()
Dim ll_color As Long
ll_color = APIColorDialog() ' 1. using this line the following
DoCmd breaks with no reason
' ll_color = 123456 ' 2. using this line instead,
the following DoCmd works ok, but it's not what I want of course
' set the color value to the database field
i_fore_color.Value = ll_color
' save the form
DoCmd.RunCommand acCmdSaveRecord
End Sub
Following are all the declarations and API functions I used (Downloaded from
various sites)
'-------------------------------------------------------------
' ------ API Declarations I use -----
'-------------------------------------------------------------
Private Type COLORSTRUC
lStructSize As Long
HWND As Long
hInstance As Long
rgbResult As Long
lpCustColors As String
Flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Const CC_SOLIDCOLOR = &H80
Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA"
(pChoosecolor As COLORSTRUC) As Long
'-------------------------------------------------------------
' ------ my wrapper function that calls the api dialog -----
'-------------------------------------------------------------
Public Function APIColorDialog() As Long
Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long
CS.lStructSize = Len(CS)
CS.HWND = hWndAccessApp
CS.Flags = CC_SOLIDCOLOR
CS.lpCustColors = String$(16 * 4, 0)
x = ChooseColor(CS)
If x = 0 Then
' ERROR - use Default White
APIColorDialog = RGB(255, 255, 255) ' White
Else
APIColorDialog = CS.rgbResult
End If
End Function
Hi there. Another problem I run into, has to do with the DoCmd.RunCommand
acCmdSaveRecord, after calling an API function.
I have a form that holds the properties of my report fields, in order to set
them at runtime. One of the properties is the color (fore, back, border),
and the fields that are used for that, are : i_fore_color, i_back_color and
i_border_color, with a little button next to them that calls the following
code (only for the 1st button, the others are the same)
It seems that after calling the APIColorDialog() function, the
DoCmd.RunCommand acCmdSaveRecord, does not work.
What is going wrong?
'-------------------------------------------------------------
' ---- Button to open the color dialog ----
'-------------------------------------------------------------
Private Sub cb_fore_color_Click()
Dim ll_color As Long
ll_color = APIColorDialog() ' 1. using this line the following
DoCmd breaks with no reason
' ll_color = 123456 ' 2. using this line instead,
the following DoCmd works ok, but it's not what I want of course
' set the color value to the database field
i_fore_color.Value = ll_color
' save the form
DoCmd.RunCommand acCmdSaveRecord
End Sub
Following are all the declarations and API functions I used (Downloaded from
various sites)
'-------------------------------------------------------------
' ------ API Declarations I use -----
'-------------------------------------------------------------
Private Type COLORSTRUC
lStructSize As Long
HWND As Long
hInstance As Long
rgbResult As Long
lpCustColors As String
Flags As Long
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Const CC_SOLIDCOLOR = &H80
Private Declare Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA"
(pChoosecolor As COLORSTRUC) As Long
'-------------------------------------------------------------
' ------ my wrapper function that calls the api dialog -----
'-------------------------------------------------------------
Public Function APIColorDialog() As Long
Dim x As Long, CS As COLORSTRUC, CustColor(16) As Long
CS.lStructSize = Len(CS)
CS.HWND = hWndAccessApp
CS.Flags = CC_SOLIDCOLOR
CS.lpCustColors = String$(16 * 4, 0)
x = ChooseColor(CS)
If x = 0 Then
' ERROR - use Default White
APIColorDialog = RGB(255, 255, 255) ' White
Else
APIColorDialog = CS.rgbResult
End If
End Function