Jump to content

Recommended Posts

Posted

Boas pessoal alguem sabe porque é que este código nao está a funcionar? ele não me avalia.

Private Sub Guardar825955_Click()
Dim dbcurrent As DAO.Database
Dim req As DAO.Recordset
Dim mensagem As String

Set dbcurrent = CurrentDb
Set req = dbcurrent.OpenRecordset("reqblockum")

If Not IsNull(DLookup("Portatil", "reqblockum", "Portatil = '" & Forms!Requisições!por825955 & "'" _
            & " AND Data =#" & Forms!Requisições!Data & "#")) Then
                    MsgBox ("O portátil já foi requisitado")
                    Exit Sub

ElseIf (prof825955.Visible = True) And (outros825955.Visible = False) Then

       
    If por825955.Value = "Portátil" Or prof825955.Value = "Professor(a)" Then
mensagem = MsgBox("Introduza um requisitante/portátil", vbOKOnly, "Laptop Manager 1.0")

    Else

    req.AddNew
    req("Data").Value = Data.Value
    req("Portatil").Value = por825955.Value
    req("Professor").Value = prof825955.Value
    req.Update
    Set req = Nothing
    MsgBox ("Dados gravados")
    por825955.Value = "Portátil"
    prof825955.Value = "Professor(a)"
    outros825955.Value = ""
    prof825955.Visible = True
    outros825955.Visible = False
    End If
    
ElseIf (prof825955.Visible = False) And (outros825955.Visible = True) Then
    

            

            
        If por825955.Value = "Projector" Or outros825955.Value = "" Then
    mensagem = MsgBox("Introduza um requisitante/portátil", vbOKOnly, "Laptop Manager 1.0")
        Else
        req.AddNew
        req("Data").Value = Data.Value
        req("Portatil").Value = por825955.Value
        req("Professor").Value = outros825955.Value
        req.Update
        Set req = Nothing
        MsgBox ("Dados gravados")
        
        por825955.Value = "Portátil"
    prof825955.Value = "Professor(a)"
    outros825955.Value = ""
    prof825955.Visible = True
    outros825955.Visible = False
        End If
        
       





End If
End Sub

Posted

Qual é o formato de Forms!Requisições!Data  ?

É que no Access o formato é mm/dd/yyyy. Se o formato não estiver correcto usa a função Format() para corrigir.

ou então altere o formato da data do sistema para o mesmo que esta usando.  Aqui no Brasil usamos dd/mm/aaaa, e os sistemas vem marcado para dd/mm/aa, sendo necessária a alteração.

Vc pode até criar uma aplicação em VBa que, ao abrir o banco ele já faça a alteração.

  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.