|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
sql with vb
Hey people i am new to this forum however i am sure you will like me!
i know a little php and sql but not much and also know a it of MS Access. My roblem is with MS Access and VB and SQL code This is what i do not understand and would lik sample code to help me understand :-) OK i have for example two tables tblUsers and tblDate In tblUsers there is loads of info about the user and in tblDate there is one entry with ID set to 1 and date set to 00/00/0000 In the main open form i have a text box and i want to get the date from the table and input it into the text box....simple right!! not for me :S So i understand that the code is: SELECT tblPaymentDate.date FROM tblPaymentDate WHERE tblPaymentDate.ID = 1; however i am not sure how to get this wrking in the form load section of the VB code. How close am i with this?: Private Sub Form_Load() Dim sqlQuery As String sqlQuery = "SELECT tblPaymentDate.date FROM tblPaymentDate WHERE tblPaymentDate.ID = 1;" DoCmd.RunSQL sqlQuery Text38.Value = "sqlQuery" End Sub Thanks very much for your help James | SharkEye.co.uk |
|
#2
|
||||
|
||||
|
Code:
Private Sub Form_Load()
Dim sqlQuery As String
Dim rst As Recordset
Dim dbs As Database
Set dbs = CurrentDb
sqlQuery = "SELECT tblPaymentDate.date AS pd FROM tblPaymentDate WHERE tblPaymentDate.ID = 1;"
Set rst = dbs.openrecordset(sqlQuery)
Text38.Value = rst("pd")
End Sub
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > sql with vb |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|