Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / August 2006

Tip: Looking for answers? Try searching our database.

What's Wrong with this code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Reiro - 28 Aug 2006 08:25 GMT
Hi ppl

the foll: code calls a query that inserts the data into a table through
parameters...
is my sql statement correct...  My table is created in design view....

Private Sub Command4_Click
On Error GoTo Err_Command4_Click

Dim count As Integer
Dim qd As QueryDef
Dim strsql As String

strsql = "select nz(max(asset_id),0)+ 1" & "from asset"

   Set qd = CurrentDb.QueryDefs("add")
   qd.Parameters("parFld1") = strsql
   qd.Parameters("parFld2") = Text2
   qd.Execute

 DoCmd.Close

stDocName = "asset_INFORMATION"
   DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command4_Click:
   Exit Sub

Err_Command4_Click:
   MsgBox Err.Description
   Resume Exit_Command4_Click
End Sub

my query is :

insert into asset (asset_id,asset_level)
values (parfld1,parfld2)

plz help....
salad - 28 Aug 2006 11:45 GMT
> Hi ppl
>
[quoted text clipped - 35 lines]
>
> plz help....

Is there a reason you are making strSQL a parameter?  WHen will you
assign the qd's SQL a value?
Reiro - 28 Aug 2006 13:08 GMT
hi ...   i came up with a solution...  i took out the sqlstr and my
insert sataement now looks like this...

insert into asset(asset_id,asset_level)
select nz(max(asset_id),0) + 1,parfld2
from asset;

it works fine.....
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.