Como Condiciono un dato de mi base de Datos
Nuevamente yo consultándote me Hisciste favor de enviarme una solución la cual la plique; Te envío el Código ya que si me hace lo que quiero pero al decirle que no quiero asignar el folio me marca un error en la parte
Private Sub Dependencia()
Select Case Me.[Tipo_Sol]
Case "2", "3", "4", "6"
IdDependencia.Enabled = False
Case Else
IdDependencia.Enabled = True
End Select
End Sub
Este es mi codigo Completo:
Public Sub ASIGNA_FOLIO()
Dim MSJ As String
Dim RSP As String
MSJ = "Desea asignar un folio a este registro....?"
RSP = MsgBox(MSJ, vbYesNo, "MENSAJE DEL SISTEMA")
If RSP = vbNo Then
MsgBox "No se asignará ningun folio a este registro", vbInformation, "MENSAJE DEL SISTEMA"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close
Else
'Dimensionamiento de Variables
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim REG As Long
Dim RS1 As Recordset
Dim strSQL1 As String
Dim REG1 As Long
Dim UF As Integer
Dim NF As Integer
Dim C As Long
Dim U As Long
'Crea la intruccion SQL para llenar el recordset
Set db = CurrentDb
If [Tipo_Sol] = 2 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios ASE];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE LA ASE"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "ASE" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 3 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios RDF];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Reclusorios del DF"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "RDF" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 4 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios RED];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Reclusorios del Estado"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "RED" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 5 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios MPI];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Materia Prima por Incidencia"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "MPI" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 6 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios GAO];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Gastos de Operacion"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "GAO" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 7 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios MTO];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Mantenimiento"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "MTO" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
End If
Me.Refresh
End If
End If
End If
End If
End If
End If
End Sub
Private Sub Form_Current()
Dependencia1
End Sub
Private Sub Tipo_Sol_AfterUpdate()
ASIGNA_FOLIO
Dependencia
End Sub
Private Sub Dependencia()
Select Case Me.[Tipo_Sol]
Case "2", "3", "4", "6"
IdDependencia.Enabled = False
Case Else
IdDependencia.Enabled = True
End Select
End Sub
Private Sub Dependencia1()
Select Case Me.[Tipo_Sol]
Case "ASE", "RED", "RDF", "GAO"
IdDependencia.Enabled =...
Private Sub Dependencia()
Select Case Me.[Tipo_Sol]
Case "2", "3", "4", "6"
IdDependencia.Enabled = False
Case Else
IdDependencia.Enabled = True
End Select
End Sub
Este es mi codigo Completo:
Public Sub ASIGNA_FOLIO()
Dim MSJ As String
Dim RSP As String
MSJ = "Desea asignar un folio a este registro....?"
RSP = MsgBox(MSJ, vbYesNo, "MENSAJE DEL SISTEMA")
If RSP = vbNo Then
MsgBox "No se asignará ningun folio a este registro", vbInformation, "MENSAJE DEL SISTEMA"
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.Close
Else
'Dimensionamiento de Variables
Dim db As Database
Dim rs As Recordset
Dim strSQL As String
Dim REG As Long
Dim RS1 As Recordset
Dim strSQL1 As String
Dim REG1 As Long
Dim UF As Integer
Dim NF As Integer
Dim C As Long
Dim U As Long
'Crea la intruccion SQL para llenar el recordset
Set db = CurrentDb
If [Tipo_Sol] = 2 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios ASE];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE LA ASE"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "ASE" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 3 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios RDF];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Reclusorios del DF"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "RDF" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 4 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios RED];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Reclusorios del Estado"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "RED" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 5 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios MPI];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Materia Prima por Incidencia"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "MPI" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 6 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios GAO];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Gastos de Operacion"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "GAO" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
Else
If [Tipo_Sol] = 7 Then
Me.Refresh
'Obtengo el conscutivo
strSQL = "SELECT * FROM [Folios MTO];"
Set rs = db.OpenRecordset(strSQL)
C = rs!Consecutivo
U = rs!Ultimo_Utilizado
MsgBox "Consecutivo a utilizar: " & C, vbInformation, "FOLIOS CONSECUTIVOS DE Mantenimiento"
strSQL1 = "SELECT * FROM [Solicitud de cheque o Depositos] Where ([ID_Registro]= " & Me.ID_Registro & ") ;"
Set RS1 = db.OpenRecordset(strSQL1)
[REG1] = RS1.RecordCount
RS1.Edit
RS1!Folio = "MTO" & "-" & C & "-" & Format(Now, "yyyy")
RS1.Update
RS1.Bookmark = RS1.LastModified
RS1.Close
Me.Refresh
rs.Edit
rs!Ultimo_Utilizado = rs!Ultimo_Utilizado + 1
rs!Consecutivo = rs!Consecutivo + 1
rs.Update
rs.Bookmark = rs.LastModified
rs.Close
Me.Refresh
End If
Me.Refresh
End If
End If
End If
End If
End If
End If
End Sub
Private Sub Form_Current()
Dependencia1
End Sub
Private Sub Tipo_Sol_AfterUpdate()
ASIGNA_FOLIO
Dependencia
End Sub
Private Sub Dependencia()
Select Case Me.[Tipo_Sol]
Case "2", "3", "4", "6"
IdDependencia.Enabled = False
Case Else
IdDependencia.Enabled = True
End Select
End Sub
Private Sub Dependencia1()
Select Case Me.[Tipo_Sol]
Case "ASE", "RED", "RDF", "GAO"
IdDependencia.Enabled =...
1 respuesta
Respuesta de jeddy
1