My Assistant
|
|
Feb 3 2006, 07:26 AM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 88 |
I have a basequery named qryFghEkonomi and a global variable, dim dak as long and a module shown below.
I then use this code in a form, it all works fine until the moment when I want to save the value to the variable and then display it in a textbox. According to the msgbox the value of dak i 0 and when trying toi assign the textbox a value i get the message can not assign that objekt a value. The funny thing is if I pull up the question manually and run it with the form open after clicking the button ( so the qry is changed according to GetDAK() ) i get the correct value but it will not be saved into the variable. Option Compare Database Option Explicit Public Function GetDAK() As Integer Dim qry As QueryDef Dim DB As Database Dim sSql As String Set DB = CurrentDb() Set qry = DB.QueryDefs("qryFghEkonomi") qry.SQL = "SELECT intDAK FROM [tblFghEkonomi] " & _ "WHERE [intFastighetsnummer]=[forms].[frmNyAlgh].[intFastighetsnummer];" dak = DMax("[intDak]", "qryFghEkonomi") Set qry = Nothing End Function In the form: Private Sub cmdGetDAK_Click() On Error GoTo Err_cmdGetDAK_Click Call GetDAK Me.txtDAK = dak MsgBox dak Exit_cmdGetDAK_Click: Exit Sub Err_cmdGetDAK_Click: MsgBox Err.Description Resume Exit_cmdGetDAK_Click End Sub |
|
|
|
oso Using vba to get single value from a table with criteria and the Feb 3 2006, 07:26 AM
ScottGem Re: Using vba to get single value from a table with criteria and Feb 3 2006, 07:41 AM
oso Re: Using vba to get single value from a table with criteria and Feb 3 2006, 07:57 AM
ScottGem Re: Using vba to get single value from a table with criteria and Feb 3 2006, 08:42 AM
schroep Re: Using vba to get single value from a table with criteria and Feb 3 2006, 10:48 AM
schroep Re: Using vba to get single value from a table with criteria and Feb 3 2006, 11:46 AM![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 09:25 AM |