View Full Version : Displaying a Variables value in a MsgBox
MachoNacho
09-05-2007, 04:13 PM
I am trying to dispaly a variable in a MsgBox. Here is what I have so far:
Dim varRecords As Variant
sqlCurrRec = "SELECT * FROM tblCreateNewUser WHERE userRequestID = " & userId
Set currdb = CurrentDb()
Set rstCurrRec = currdb.OpenRecordset(sqlCurrRec, dbOpenDynaset)
DoCmd.Close acForm, "frmCreateNewUser"
varRecords = rstCurrRec
MsgBox "The value of my var = " & varRecords.Value
Any help would be appreciated.
You do not need the ".Value", just the varRecords.
It would also be better to use an Integer, Single or Double for the Variable type.
You are however setting the value after closing the "Form" which probably will not work.
MachoNacho
09-06-2007, 09:04 AM
Ok I have tried the last suggestion but it did not work. Let me re-phase my question.
I have a form that a user will be using and after they complete the form I want to run a SQL script and extract the data and display that data in a msgbox to have them confirm the data is correct. So here is all of my code which is very simple. Any and all help will be appreciated. Thanks in advance for all those who share their knowledge with me.
Public Function getData()
' This is where I need to do a query and extract the data
Dim varRecords As Variant
Dim sqlCurrRec As String
userId = Me.userRequestID
sqlCurrRec = "SELECT * FROM tblCreateNewUser WHERE userRequestID = " & userId
Set currdb = CurrentDb()
Set rstCurrRec = currdb.OpenRecordset(sqlCurrRec, dbOpenDynaset)
varRecords = rstCurrRec
MsgBox "Is the following data correct? " & varRecords
DoCmd.Close acForm, "frmCreateNewUser"
End Function
asingh
09-09-2007, 09:10 PM
Try this...via adodb
Public Function Get_data
'queries for transaction.
Dim rst as ADODB.recordset
Dim varRecords as Double
Set rst as New Adodb.recordset
rst.Open "SELECT * FROM tblCreateNewUser WHERE userRequestID = ' " & userId & " ' ", Currentproject.connection, adopenstatic
varRecords = rst.recordcount 'get the record count
rst.close
set rst = nothing 'close all instances
MsgBox "Is the following data correct? " & varRecords
DoCmd.Close acForm, "frmCreateNewUser"
End Function
regards,
asingh
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.