G
Guest
First time post-er, novice VB Programme
experienced with lisp (autodesk) and Lingo (macromedia
boy vb is different...
version: Access X
On to the question
I have a form with many fields listing the current record of a table. The form has a list box referencing the 'key' item for each record in the table. I am using bookmark to change the current record set by selecting an item in the list box
The problem I am having is reversing the scenario. When the user adds a new record. The first field is brought in focus and must be entered. I am using the AfterUpdate method on the 'SYM' field to requery the list box and highlight the previously just entered symbol
The problem 'I think' is the requery is working but the new 'SYM' entry hasn't actually been put in the table yet, so its not part of the requery
How can I force an entry so the list box can do its job
I'm posting my code for the form
Private Sub Form_AfterInsert(
Me![List7].Requer
End Su
Private Sub Form_Load(
Me![SYM].SetFocu
End Su
Private Sub List7_AfterUpdate(
' Find the record that matches the control
Dim rs As Objec
Set rs = Me.Recordset.Clon
rs.FindFirst "[SYM] = '" & Me![List7] & "'
If Not rs.EOF Then Me.Bookmark = rs.Bookmar
End Su
Private Sub SYM_AfterUpdate(
Dim lngrecordnum As Lon
'!!!!looking for a way to highlight the newly entered symbol in the listbo
lngrecordnum = Me.Form.CurrentRecor
Me![List7].Requer
Me![List7].Selected(lngrecordnum) = Tru
End Su
Private Sub SYM_BeforeUpdate(Cancel As Integer
Dim rs As ADODB.Recordse
Set rs = New ADODB.Recordse
rs.ActiveConnection = CurrentProject.Connectio
rs.CursorType = adOpenStati
rs.LockType = adLockOptimisti
rs.CursorLocation = adUseServe
rs.Open "Select * from tblMasterPlantList " &
"WHERE SYM = " & ReplaceApostrophe([SYM]),
Options:=adCmdTex
If Not rs.EOF The
MsgBox "You entered a Symbol that already exists, " & vbCrLf &
"Please Change your Symbol Abbreviation!
'this ensures the focus stays on current fiel
Cancel = Tru
End I
'set to nothin
rs.Clos
Set rs = Nothin
End Su
Public Function ReplaceApostrophe(strSymbol As String) As Strin
'Surround text with apostrophes and replace any apostrophies i
'the string with two apostrophe
ReplaceApostrophe = "'" &
Replace(strSymbol, "'", "''") & "'
End Functio
Private Sub btnAddRecord_Click(
On Error GoTo Err_btnAddRecord_Clic
DoCmd.GoToRecord , , acNewRe
Me![SYM].SetFocu
Exit_btnAddRecord_Click
Exit Su
Err_btnAddRecord_Click
MsgBox Err.Descriptio
Resume Exit_btnAddRecord_Clic
End Su
Private Sub btnDeleteRecord_Click(
On Error GoTo Err_btnDeleteRecord_Clic
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer7
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer7
Me![List7].Requer
Exit_btnDeleteRecord_Click
Exit Su
Err_btnDeleteRecord_Click
MsgBox Err.Descriptio
Resume Exit_btnDeleteRecord_Clic
End Su
Private Sub btnOK_Click(
On Error GoTo Err_btnOK_Clic
DoCmd.Clos
Exit_btnOK_Click
Exit Su
Err_btnOK_Click
MsgBox Err.Descriptio
Resume Exit_btnOK_Clic
End Su
Robert Good
experienced with lisp (autodesk) and Lingo (macromedia
boy vb is different...
version: Access X
On to the question
I have a form with many fields listing the current record of a table. The form has a list box referencing the 'key' item for each record in the table. I am using bookmark to change the current record set by selecting an item in the list box
The problem I am having is reversing the scenario. When the user adds a new record. The first field is brought in focus and must be entered. I am using the AfterUpdate method on the 'SYM' field to requery the list box and highlight the previously just entered symbol
The problem 'I think' is the requery is working but the new 'SYM' entry hasn't actually been put in the table yet, so its not part of the requery
How can I force an entry so the list box can do its job
I'm posting my code for the form
Private Sub Form_AfterInsert(
Me![List7].Requer
End Su
Private Sub Form_Load(
Me![SYM].SetFocu
End Su
Private Sub List7_AfterUpdate(
' Find the record that matches the control
Dim rs As Objec
Set rs = Me.Recordset.Clon
rs.FindFirst "[SYM] = '" & Me![List7] & "'
If Not rs.EOF Then Me.Bookmark = rs.Bookmar
End Su
Private Sub SYM_AfterUpdate(
Dim lngrecordnum As Lon
'!!!!looking for a way to highlight the newly entered symbol in the listbo
lngrecordnum = Me.Form.CurrentRecor
Me![List7].Requer
Me![List7].Selected(lngrecordnum) = Tru
End Su
Private Sub SYM_BeforeUpdate(Cancel As Integer
Dim rs As ADODB.Recordse
Set rs = New ADODB.Recordse
rs.ActiveConnection = CurrentProject.Connectio
rs.CursorType = adOpenStati
rs.LockType = adLockOptimisti
rs.CursorLocation = adUseServe
rs.Open "Select * from tblMasterPlantList " &
"WHERE SYM = " & ReplaceApostrophe([SYM]),
Options:=adCmdTex
If Not rs.EOF The
MsgBox "You entered a Symbol that already exists, " & vbCrLf &
"Please Change your Symbol Abbreviation!
'this ensures the focus stays on current fiel
Cancel = Tru
End I
'set to nothin
rs.Clos
Set rs = Nothin
End Su
Public Function ReplaceApostrophe(strSymbol As String) As Strin
'Surround text with apostrophes and replace any apostrophies i
'the string with two apostrophe
ReplaceApostrophe = "'" &
Replace(strSymbol, "'", "''") & "'
End Functio
Private Sub btnAddRecord_Click(
On Error GoTo Err_btnAddRecord_Clic
DoCmd.GoToRecord , , acNewRe
Me![SYM].SetFocu
Exit_btnAddRecord_Click
Exit Su
Err_btnAddRecord_Click
MsgBox Err.Descriptio
Resume Exit_btnAddRecord_Clic
End Su
Private Sub btnDeleteRecord_Click(
On Error GoTo Err_btnDeleteRecord_Clic
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer7
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer7
Me![List7].Requer
Exit_btnDeleteRecord_Click
Exit Su
Err_btnDeleteRecord_Click
MsgBox Err.Descriptio
Resume Exit_btnDeleteRecord_Clic
End Su
Private Sub btnOK_Click(
On Error GoTo Err_btnOK_Clic
DoCmd.Clos
Exit_btnOK_Click
Exit Su
Err_btnOK_Click
MsgBox Err.Descriptio
Resume Exit_btnOK_Clic
End Su
Robert Good