Title: Message
You have more than one issue here.  One, you cannot set LeaveID in that manner.  You are trying to assign a string value to an integer, and this will not produce an error message, but the value assigned will probably be zero; while you have SQL code in the string on the right of the equals sign, it isn't actually a query and will not produce a result the way you would get it from a query.  Secondly, to update a value in a table, you need to open that table as a recordset, then use more code to find and edit the appropriate entries.  It's all there in the Help screens, though not easy to find.  Rather than try to give you the code, here is how I got to an example in Help:  in the Help/Index tab, type "update".  It should come up with a page on "Update Method" and the example there may help you further.
 
Tobi
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of RAJESH DESAI
Sent: Thursday, January 05, 2006 1:05 PM
To: Access1; Access2; Access3
Subject: [AccessDevelopers] Help with select statement

Hi,
 
Please refer the following code. I have put this code in the code window of the form which is bound to tblEmployeeMaster.
 
What I basically want is, from the year entered in the form by the user, I want to pick the YearID from tblLeaveYearMaster. "ID" is a PK of data type AutoNumber and Year is of data type long integer.
 
On running the following code, no matter what the year is selected in the form, it invariably store value 0 in LeaveYearID variable.
 
Please guide me.
 
 
Private Sub Form_AfterUpdate()
LeaveYearID As Integer
Dim dbs As Database
Set dbs = CurrentDb
 
Months = NoOfMonths(Fdate, LDate, DOJ, DOD)
LeaveYearID = "Select tblLeaveYearMaster.ID from tblLeaveYearMaster " _
& " WHERE tblLeaveYearMaster.Year = " & LeaveYear
dbs.Close
End Sub
Regards,
 
Rajesh Desai


Yahoo! Photos
Ring in the New Year with Photo Calendars. Add photos, events, holidays, whatever.


Please zip all files prior to uploading to Files section.




SPONSORED LINKS
Microsoft access developer Microsoft access help Microsoft access database
Microsoft access training Microsoft access training course Microsoft access programming


YAHOO! GROUPS LINKS




Reply via email to