I need help, for query for access

anamo65

New member
Local time
Today, 07:58
Joined
May 2, 2020
Messages
6
mi código es
DoCmd.OpenForm "FrmAntecedentesGinecoObstetricos", _
WhereCondition: = "Matricula =" & Me.lstAlumnos
 
can you write in English?

what datatype is Matricula and what datatype is the Bound Column of the listbox, lstAlumnos?

try:

DoCmd.OpenForm FormName:="FrmAntecedentesGinecoObstetricos", _
WhereCondition: = "Matricula =" & Me.lstAlumnos
 
Private Sub Opción22_Click ()
Dim primero como DAO.Recordset, SQL como cadena


Code Tags Added by UG
Please use Code Tags when posting VBA Code
https://www.access-programmers.co.u...e-use-code-tags-when-posting-vba-code.240420/
Code:
    En error GoTo ManipulaError
    SQL = "SELECCIONAR * DESDE tbl_Pacientes DONDE Matricula = '" & Me.lstAlumnos & "'"
    Establecer rst = CurrentDb.OpenRecordset (SQL, dbOpenForwardOnly)
    Con la primera
        Me.txtMatricula = txtMatricula
        Me.txtBusqueda = txtBusqueda
        Me.lstAlumnos = lstAlumnos
        MsgBox (SQL)
        MsgBox (lstAlumnos)
        'MsgBox (txtMatricula)
        DoCmd.OpenForm "FrmAntecedentesGinecoObstetricos", _
        WhereCondition: = "Matricula =" & "Me.lstAlumnos"
       
       
    Terminar con
    rst.Close: Set rst = Nothing
    Salir Sub
           
ManipulaError:
    Si no, primero no hay nada, primero cierre: establezca primero = nada
    MsgBox Err.Description, vbCritical, "Atencion"
End Sub
 
Last edited by a moderator:
Matricula es cadena variable
La inscripción es Id y está vinculada a un catálogo de nombres

Edit by jdraw:
Google translate : Spanish to English
Enrollment is variable string
The registration is Id and is linked to a catalog of names
 
Last edited by a moderator:
SQL = "SELECCIONAR * DESDE tbl_Pacientes DONDE Matricula = '" & Me.lstAlumnos & "'"

I think you are writing in Spanish. I understand that "DONDE" = "WHERE" ... So my question is:- Is Spanish SQL written in Spanish? I mean is "DONDE" correct, or should it be "WHERE" I would look into that first before you go any further.
 
Other thing that look wrong is that you should dimension the SQL variable as string somewhere like this:- DIM SQL as String
 
Me.txtMatricula = txtMatricula Me.txtBusqueda = txtBusqueda Me.lstAlumnos = lstAlumnos


These look wrong:-

Code:
        Me.txtMatricula = txtMatricula
        Me.txtBusqueda = txtBusqueda
        Me.lstAlumnos = lstAlumnos
I would expect to see something more like this

Code:
        Me.txtMatricula = rst!txtMatricula
        Me.txtBusqueda = rst!txtBusqueda
        Me.lstAlumnos = rst!lstAlumnos
But I wouldn't expect to see text boxes like "txtMatricula" as field names
 
Code:
    En error GoTo ManipulaError
    SQL = "SELECCIONAR * DESDE tbl_Pacientes DONDE Matricula = '" & Me.lstAlumnos & "'"
    Establecer rst = CurrentDb.OpenRecordset (SQL, dbOpenForwardOnly)
    Con la primera
        Me.txtMatricula = txtMatricula
        Me.txtBusqueda = txtBusqueda
        Me.lstAlumnos = lstAlumnos
        MsgBox (SQL)
        MsgBox (lstAlumnos)
        'MsgBox (txtMatricula)
        DoCmd.OpenForm "FrmAntecedentesGinecoObstetricos", _
        WhereCondition: = "Matricula =" & "Me.lstAlumnos"
      
      
    Terminar con
    rst.Close: Set rst = Nothing
    Salir Sub
          
ManipulaError:
    Si no, primero no hay nada, primero cierre: establezca primero = nada
    MsgBox Err.Description, vbCritical, "Atencion"
End Sub

And I don't see any way of looping through the records, I would expect to see something like this:-

Code:
                    Do Until rst.EOF
                        lngAgeRangeRelated = rst!AgeRangeRelated
                        rst.MoveNext
                    Loop
 
anamo65,
Como el inglés no es su idioma nativo, y dado que la mayoría de los miembros del foro hablan inglés, le recomiendo que cree su publicación en español, luego, utilizando el traductor de Google, convierta su mensaje al inglés. La traducción es ciertamente más que adecuada para la comunicación de los puntos clave de su publicación.
Buena suerte.
 
All in all it is apparent that you don't seem to understand what you are doing. My guess is you have copied some code from the internet somewhere and Hacked it around to suit your purposes, but it's not working.

I think it would be a good idea for you to explain in detail what you are trying to do, however seeing as you're having trouble communicating in English, you may need to find a Spanish orientated forum, if indeed Spanish is your primary language.

I have an interest in Spanish and would relish the idea of communicating with you in Spanish, however I don't have the time or inclination at the moment. On top of that, that would exclude most of the English speakers from providing help, although there may be a few like me who have an interest in Spanish and would be interested in copying and pasting to and from Google to try and communicate with you.
 
I note this website:-


which I believe is in Spanish shows the where clause in the English "WHERE" NOT "DONDE"

So I think my suspicion that there is some issue with your understanding of the SQL is correct.
 
There's a course here which is free and is in Spanish which might help you develop your SQL skills...


However it doesn't cover recordset Loops, and I don't know how to find Spanish lessons on how to use recordset loops. I'm sure you can work out the correct search terms for finding such things in Spanish. Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom