I
Iram
Hello.
I am a dork. I am trying to get a button on a form to perform three
different tasks. Below is a mesh of three codes that I got from different
buttons. The button name is "Siguiente Pagina".
I need the button to perform the following...
1. Create a code using the vba- this works fine.
2. Render the data on the form to the table- i don't think this is working.
3. Open a form called "frm_AltaDeRegistrosPagina3-Cuestionario"- this is not
working.
Can you help me figure out what is wrong?
Thank you,
Iram Alvarez
Private Sub Siguiente_Pagina_Click()
On Error GoTo HandleErr
Dim tmpStr As String
Dim sP As String
Dim sM As String
Dim sN As String
Dim dtFECHADENACIMIENTO As String
Dim sC As String
Dim i As Integer
Dim OK As Boolean
Dim stDocName As String
Dim stLinkCriteria As String
OK = False
'get first letter of ApellidoPaterno
sP = UCase(Left(Me.ApellidoPaterno, 1))
'loop thru the name starting at the second letter
For i = 2 To Len(Me.ApellidoPaterno)
tmpStr = UCase(Mid(Me.ApellidoPaterno, i, 1))
'is letter in the string?
OK = InStr(1, "AEIOU", tmpStr)
If OK Then
'found a vowel - get out
Exit For
End If
Next
'get second letter of ApellidoPaterno
If OK Then
'vowel
sP = sP & tmpStr
Else
'no vowel
sP = sP & UCase(Mid(Me.ApellidoPaterno, 2, 1))
End If
' get letter from ApellidoMaterno
If Len(Trim(Nz(Me.ApellidoMaterno, ""))) > 0 Then
sM = UCase(Left(Me.ApellidoMaterno, 1))
End If
' get letter from Nombre
If Len(Trim(Nz(Me.Nombre, ""))) > 0 Then
sN = UCase(Left(Me.Nombre, 1))
End If
'process FECHADENACIMIENTO
dtFECHADENACIMIENTO = Format(Month(Me.FechaDeNacimiento), "00") & _
Format(Day(Me.FechaDeNacimiento), "00") & _
Right(Year(Me.FechaDeNacimiento), 2)
'add them together
Me.Codigo = sP & sM & sN & "-" & dtFECHADENACIMIENTO
Handle_Exit:
Exit Sub
HandleErr:
MsgBox Err.Number, Err.Description
Resume Handle_Exit
Me.Dirty = False
stDocName = "frm_AltaDeRegistrosPagina3-Cuestionario"
stLinkCriteria = "[Codigo]=" & "'" & Me![Codigo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Siguiente_Pagina_Click:
Exit Sub
End Sub
I am a dork. I am trying to get a button on a form to perform three
different tasks. Below is a mesh of three codes that I got from different
buttons. The button name is "Siguiente Pagina".
I need the button to perform the following...
1. Create a code using the vba- this works fine.
2. Render the data on the form to the table- i don't think this is working.
3. Open a form called "frm_AltaDeRegistrosPagina3-Cuestionario"- this is not
working.
Can you help me figure out what is wrong?
Thank you,
Iram Alvarez
Private Sub Siguiente_Pagina_Click()
On Error GoTo HandleErr
Dim tmpStr As String
Dim sP As String
Dim sM As String
Dim sN As String
Dim dtFECHADENACIMIENTO As String
Dim sC As String
Dim i As Integer
Dim OK As Boolean
Dim stDocName As String
Dim stLinkCriteria As String
OK = False
'get first letter of ApellidoPaterno
sP = UCase(Left(Me.ApellidoPaterno, 1))
'loop thru the name starting at the second letter
For i = 2 To Len(Me.ApellidoPaterno)
tmpStr = UCase(Mid(Me.ApellidoPaterno, i, 1))
'is letter in the string?
OK = InStr(1, "AEIOU", tmpStr)
If OK Then
'found a vowel - get out
Exit For
End If
Next
'get second letter of ApellidoPaterno
If OK Then
'vowel
sP = sP & tmpStr
Else
'no vowel
sP = sP & UCase(Mid(Me.ApellidoPaterno, 2, 1))
End If
' get letter from ApellidoMaterno
If Len(Trim(Nz(Me.ApellidoMaterno, ""))) > 0 Then
sM = UCase(Left(Me.ApellidoMaterno, 1))
End If
' get letter from Nombre
If Len(Trim(Nz(Me.Nombre, ""))) > 0 Then
sN = UCase(Left(Me.Nombre, 1))
End If
'process FECHADENACIMIENTO
dtFECHADENACIMIENTO = Format(Month(Me.FechaDeNacimiento), "00") & _
Format(Day(Me.FechaDeNacimiento), "00") & _
Right(Year(Me.FechaDeNacimiento), 2)
'add them together
Me.Codigo = sP & sM & sN & "-" & dtFECHADENACIMIENTO
Handle_Exit:
Exit Sub
HandleErr:
MsgBox Err.Number, Err.Description
Resume Handle_Exit
Me.Dirty = False
stDocName = "frm_AltaDeRegistrosPagina3-Cuestionario"
stLinkCriteria = "[Codigo]=" & "'" & Me![Codigo] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Siguiente_Pagina_Click:
Exit Sub
End Sub