Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 06-09-2009, 05:06 AM
LilyMarie LilyMarie is offline
Registered User
 
Join Date: 26 Feb 2009
Location: U.S
MS Office Version:Excel 2003
Posts: 42
LilyMarie is becoming part of the community
Getting Error in text data type

Please Register to Remove these Ads

Hello everyone,

Not getting text data types.

I have use this code :

Code:
Private Sub Command6_Click()
Dim ssql As String
ssql = "insert into table1(name,rollno,reason) values('" & Text0.Value & "'," & Text2.Value & ",'" & Text4.Value & "')"
DoCmd.RunSQL ssql
End Sub
Can anyone solve this problem
Reply With Quote
  #2  
Old 06-09-2009, 07:53 AM
bhill bhill is offline
Registered User
 
Join Date: 20 Mar 2008
Location: Buffalo, NY USA
Posts: 42
bhill is becoming part of the community
Re: Getting Error in text data type

try this:

Code:
ssql = "INSERT INTO Table1 ( name, rollno, reason )" & _
        " SELECT '" & Me.text0.value & "' AS Expr1, '" & Me.text2.value & "' AS Expr2, '" & Me.text4.value & "' AS Expr3;"
Also, I prefaced the field references with "Me", assuming the button is on the same form where the fields are.
Reply With Quote
  #3  
Old 06-15-2009, 07:08 AM
LilyMarie LilyMarie is offline
Registered User
 
Join Date: 26 Feb 2009
Location: U.S
MS Office Version:Excel 2003
Posts: 42
LilyMarie is becoming part of the community
Re: Getting Error in text data type

Hi,

Thanks for your reply this code works perfectly.

Thanks once again.
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
Refbacks are Off

Forum Jump