PDA

View Full Version : VBA code



Kundan
12-26-2018, 01:39 AM
The Following is giving too few arguments error:
Dim dbs As DAO.Database
Dim rst As DAO.Recordset2


'Get the database, recordset, and attachment field
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("SELECT EMAIL, NM FROM [Tbl_Personal] WHERE [NM]= BE")
strPassword = rst("EMAIL")
17 rst.Close
18 CurrentDb.Close


The table Tbl_Personal has 2 fields NM & EMAIL. BE is a string stored in NM.

OBP
12-26-2018, 02:23 AM
Well I prefer to use a string variable to hold the SQL for the recordset.
ie

Dim rs As Object

Dim SQL As String



SQL = "SELECT Que_CallNumber.* " & _

"FROM Que_CallNumber " & _

"WHERE DealerCode = " & Me.Dealercode

Set rs = CurrentDb.OpenRecordset(SQL)



The other problem could be that it is not treating BE as a string and you may have to change it in to one using code like.
"WHERE DealerCode = '" & Me.Dealercode & "'"

Kundan
12-26-2018, 09:47 PM
Well I prefer to use a string variable to hold the SQL for the recordset.
ie

Dim rs As Object

Dim SQL As String



SQL = "SELECT Que_CallNumber.* " & _

"FROM Que_CallNumber " & _

"WHERE DealerCode = " & Me.Dealercode

Set rs = CurrentDb.OpenRecordset(SQL)



The other problem could be that it is not treating BE as a string and you may have to change it in to one using code like.
"WHERE DealerCode = '" & Me.Dealercode & "'"


Thanks a Lot!!! GOD BLESS YOU!!!