Anytime you're referencing a control to get its value, you need the
reference to the control outside of quotes.
DoCmd.OpenForm "CAUSA 2", , , "[idDepartamento]=" &
[forms]![inicial]![elegir]
It would help if you said what problems you're having, rather than us
having
to guess...
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Douglas, you suppose OK! , but I continue having problems! HELP ME PLEASE!
I attach all INICIAL Form code here:
Note: I use an initial Form "INICIAL" with a ComboBox called "ELEGIR" to
choose "ID" (autonumber) and "Descripcion" (text) from the table
"dbo_departamento" ... then, this selection Open the Form "CAUSA 2" with
the
filtered records in the table "dbo_causa"
Also, I need that the first selection in the ComboBox can be made only
once!!! to prevent another selection.
in all the cases, I need that the ComboBox shows the two columns "ID"and
"Description" ... before, after and subsequently, after reload the mdb
What changes I must make in this code?
Thanks in advance, and sorry for my english!
Private Sub Comando6_Click()
If Not IsNull([ELEGIR]) Then
DoCmd.OpenForm "CAUSA 2", , ,
"[idDepartamento]=[forms]![inicial]![elegir]"
End If
DoCmd.Close acForm, "inicial"
End Sub
Private Sub Elegir_AfterUpdate()
DoCmd.SetWarnings False
DoCmd.RunSQL "Insert into uDepartamento (uDepartamento, uDescripcion )
"values(" & elegir.column(0) & ", '" & elegir.column(1) & "')"
End Sub
Private Sub Elegir_GotFocus()
If DCount("uDepartamento", "uDepartamento") = 0 Then
ELEGIR.RowSource = "select ID,Descripcion from dbo_Departamento"
Else
ELEGIR.RowSource = "select uDepartamento, uDescripcion from A"
End If
End Sub
Private Sub Form_Current()
última = DLast("uDepartamento & uDescripcion ", "A")
End Sub
Douglas J. Steele said:
What data types are uDepartmento and uDescripcion? For the purposes of
illustration, I'll assume uDepartmento is Numeric, and uDescripcion is Text.
DoCmd.RunSQL "Insert into uDepartamento (uDepartamento, uDescripcion )
values(" & elegir.column(0) & ", '" & elegir.column(1) & "')"
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hello!
I need Help with this line of code ... with error
DoCmd.RunSQL "Insert into uDepartamento (uDepartamento, uDescripcion )
values(elegir.column(0), elegir.column(1))"
Thanks!