Boa noite à todos,
Desisti de fazer conforme havia pedido ajuda. Achei uma outra solução, vejamos:
a imagem abaixo representa uma caixa de listagem com select que busca informações dos itens, nas
caixas de texto, cada vez que clico em um item ele vai para uma delas. (arquivo adaptado de um exemplo aqui do fórum)
O problema agora é que não consigo abrir o relatório para impressão com esses itens, ou seja buscando a informação completa deles
jogando-os no relatório. O relatório abre em branco ou em algumas tentativas imprime a tela do formulário e não o relatório com os dados.
No botão imprimir o código ao clicar está:
Private Sub Comando12_Click()
On Error Resume Next
DoCmd.OpenReport "REstoGer", acViewPreview, "", "[DescP] = forms![teste]![SuaCombo] "", acNormal"
If MsgBox("Impressão da Ficha?", vbOKCancel + vbQuestion, "Confirmação de Impressão") = vbOK Then
DoCmd.RunCommand acCmdPrint
End If
End Sub
SuaCombo é a caixa de listagem, quando seleciono alguma coisa ele imprime a tela do formulário e nem abre o relatório.
já mudei diversas vezes esse código e sem sucesso, não consigo capturar os registros selecionados.
outra coisa de que preciso é um código para limpar as caixas de texto, após itens selecionados só ficam limpas após fechar e abrir novamente o formulário
na caixa de listagem adaptei o código assim:
Private Sub SuaCombo_AfterUpdate()
If IsNull(Me.txt1) Then
If Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt4 Or Me.SuaCombo = Me.txt5 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt1 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt2) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt4 Or Me.SuaCombo = Me.txt5 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt2 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt3) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt4 Or Me.SuaCombo = Me.txt5 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt3 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt4) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt5 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt4 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt5) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt4 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt5 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt6) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt4 _
Or Me.SuaCombo = Me.txt7 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt6 = Me.SuaCombo
End If
ElseIf IsNull(Me.txt7) Then
If Me.SuaCombo = Me.txt1 Or Me.SuaCombo = Me.txt2 Or Me.SuaCombo = Me.txt3 Or Me.SuaCombo = Me.txt4 _
Or Me.SuaCombo = Me.txt6 Or Me.SuaCombo = Me.txt8 Or Me.SuaCombo = Me.txt9 _
Or Me.SuaCombo = Me.txt10 Or Me.SuaCombo = Me.txt11 Or Me.SuaCombo = Me.txt12 Or Me.SuaCombo = Me.txt13 _
Or Me.SuaCombo = Me.txt14 Or Me.SuaCombo = Me.txt15 Or Me.SuaCombo = Me.txt16 Or Me.SuaCombo = Me.txt17 _
Or Me.SuaCombo = Me.txt18 Or Me.SuaCombo = Me.txt19 Or Me.SuaCombo = Me.txt20 Or Me.SuaCombo = Me.txt21 _
Or Me.SuaCombo = Me.txt22 Or Me.SuaCombo = Me.txt23 Or Me.SuaCombo = Me.txt24 Or Me.SuaCombo = Me.txt25 _
Or Me.SuaCombo = Me.txt26 Then
MsgBox "Esse Código já foi escolhido."
Cancel = True
Else
Me.txt7 = Me.SuaCombo
End If
End If
Else
MsgBox "Já foi escolhido o número máximo de registros", vbOKOnly + vbInformation, "ATENÇÃO"
End If
End Sub