G
Guest
The user is allowed to pick a vegetation code (VEGCODE) from a look-up table
on the form. I want 2 other controls on the form to be automatically
populated with the common name and latin name for the vegetation species (so
the user knows which species the vegcode belongs...sometimes people know
common names...others latin names). The latin and common names are values
already contained within the look-up for the veg code.
The code I have works....the latin/common names associated to the vegcode
are written to the table when the veg species is added.....howvever I want
these names to appear in the form controls before the user writes the new
record (just in case they're not sure which species the code belongs to....
I don't understand why the latin/common names are written to the table but
are not visibly populated on the form!!!
the code is as follows:
Private Sub frmVEG_CODE_AfterUpdate()
Dim dbs As Database
Dim qryveg As QueryDef
Dim recset As Recordset
Dim prm As Variant
Set dbs = CurrentDb
Set qryveg = dbs.CreateQueryDef("")
prm = Forms("UNDERSTORY").Controls("frmVEG_CODE").Value
sqlout "SELECT [LOOK_VEGSPP].[VEG_SPPCODE], [LOOK_VEGSPP].[LATIN],
[LOOK_VEGSPP].[COMMON], [LOOK_VEGSPP].[VEG_TYPE] " & _
"FROM [LOOK_VEGSPP] " & _
"WHERE ((([LOOK_VEGSPP].[VEG_SPPCODE]) = '" & prm & "'));", qryveg
End Sub
Function sqlout(strsql As String, qryveg As QueryDef)
Dim recset As Recordset
qryveg.SQL = strsql
Set recset = qryveg.OpenRecordset
'Debug.Print strsql
With recset
Forms("UNDERSTORY").Controls("frmLATIN").Value = !LATIN
Forms("UNDERSTORY").Controls("frmVEG_TYPE").Value = !VEG_TYPE
Forms("UNDERSTORY").Controls("frmCOMMON").Value = !COMMON
End With
End Function
Does anyone know why my form controls do not automatically/visibly populate???
any clarification would be appreciated....
on the form. I want 2 other controls on the form to be automatically
populated with the common name and latin name for the vegetation species (so
the user knows which species the vegcode belongs...sometimes people know
common names...others latin names). The latin and common names are values
already contained within the look-up for the veg code.
The code I have works....the latin/common names associated to the vegcode
are written to the table when the veg species is added.....howvever I want
these names to appear in the form controls before the user writes the new
record (just in case they're not sure which species the code belongs to....
I don't understand why the latin/common names are written to the table but
are not visibly populated on the form!!!
the code is as follows:
Private Sub frmVEG_CODE_AfterUpdate()
Dim dbs As Database
Dim qryveg As QueryDef
Dim recset As Recordset
Dim prm As Variant
Set dbs = CurrentDb
Set qryveg = dbs.CreateQueryDef("")
prm = Forms("UNDERSTORY").Controls("frmVEG_CODE").Value
sqlout "SELECT [LOOK_VEGSPP].[VEG_SPPCODE], [LOOK_VEGSPP].[LATIN],
[LOOK_VEGSPP].[COMMON], [LOOK_VEGSPP].[VEG_TYPE] " & _
"FROM [LOOK_VEGSPP] " & _
"WHERE ((([LOOK_VEGSPP].[VEG_SPPCODE]) = '" & prm & "'));", qryveg
End Sub
Function sqlout(strsql As String, qryveg As QueryDef)
Dim recset As Recordset
qryveg.SQL = strsql
Set recset = qryveg.OpenRecordset
'Debug.Print strsql
With recset
Forms("UNDERSTORY").Controls("frmLATIN").Value = !LATIN
Forms("UNDERSTORY").Controls("frmVEG_TYPE").Value = !VEG_TYPE
Forms("UNDERSTORY").Controls("frmCOMMON").Value = !COMMON
End With
End Function
Does anyone know why my form controls do not automatically/visibly populate???
any clarification would be appreciated....