Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 7th, 2015, 01:10 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Feb 2015
Location: Toronto
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL in form on Access2013 using VBA

This is my first time posting anywhere. I am a newbie Access2013/VBA programmer trying to write my first application.

I have a table T03 with three fields below

T03-ID-Service-Or-Event-Type autonumber
T03-Description-Short text
T03-Description-Long text

I can display a combo box with all three fields on each line.
I want to refer to all three fields from the one line user selected so I can refer/use them everywhere in my application.

With the code below I get error as follows:
" runtime error '-2147217900 (80040e14)' Syntax error in FROM clause'

A friend told me I can't use SQL inside a form.

Private Sub Combo01_Change()

Dim str_SQL_Get_Service_Type As String
Set g_cn = New ADODB.Connection
g_cn.Open "Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Counting.accdb"
MsgBox Combo01.Value ' this does display the 1st field of line selected

Set g_rs_T03 = New ADODB.Recordset
g_rs_T03.ActiveConnection = CurrentProject.Connection

str_SQL_Get_Service_Type = "SELECT * FROM T03_Service_Or_Event_Types WHERE T03_ID_Service_Or_Event_Type = Combo01.Value"

g_rs_T03.Open str_SQL_Get_Service_Type, g_cn, adOpenStatic, adLockOptimistic, adCmdTable

End Sub

What am I doing wrong. I hope this is all clearly stated.

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert table to different form using vba mkhanna Excel VBA 3 June 25th, 2010 04:58 AM
delete a user form using vba sms Access VBA 2 June 27th, 2008 07:15 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM
VBA - Form Refresh lxu Access 2 March 4th, 2004 11:13 AM
VBA - Form refresh lxu XML 2 March 3rd, 2004 01:49 PM

All times are GMT -4. The time now is 04:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.