Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Forms

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-12-2009, 11:46 AM
Novice
 
Join Date: Feb 2009
Posts: 6
cjamps is on a distinguished road
Default combo not updating form

First Combo - working appropriately
Private Sub cmbDSerialNumber_AfterUpdate()
Dim rs As DAO.Recordset
If Not IsNull(Me.cmbDSerialNumber) Then
'Save before move.
If Me.Dirty Then
Me.Dirty = False
End If
'Search in the clone set.
Set rs = Me.RecordsetClone
rs.FindFirst "dserialnumber = '" & cmbDSerialNumber & "'"
If rs.NoMatch Then
MsgBox "There is no task for: " & cmbDSerialNumber & " Add Task?", vbYesNoCancel
Else
'Display the found record in the form.
Me.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End If
End Sub

'User presses edit task command button
Private Sub EditTaskBttn_Click()
DoCmd.OpenForm "EditTask", , , "[TSerialNumber] = '" & Me.cmbDSerialNumber.Column(0) & "'", acFormEdit
End Sub
' Loading Edit Task Form
Private Sub Form_Load()
Me.TSerialNumber = Forms![Main Switchboard]!cmbDSerialNumber
Me.Caption = "Serial Number: " & Me!TSerialNumber.Value
End Sub
'Query for Second Combo
SELECT TaskList.TSerialNumber, TaskList.[No], TaskList.Task
FROM Dockets INNER JOIN TaskList ON Dockets.DSerialNumber = TaskList.TSerialNumber
WHERE (((TaskList.TSerialNumber)=[Forms]![Main Switchboard]![cmbDSerialNumber]));
'Loading Second Combo
Private Sub CmbTSerialNumber_AfterUpdate()
Me.RecordsetClone.FindFirst "[no] = " & Me!CmbTSerialNumber.Column(2)
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
'I put a breakpoint by
Me.RecordsetClone.FindFirst "[no] = " & Me!CmbTSerialNumber.Column(1)
'then I press F8 to step into the next 2 statements
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
In the immediate window ? no is the correct task number but ? Me!CmbTSerialNumber.Column(1) is alway = to 1. If I add a watch to both those variables they are empty. After the sub is finished ? no is empty and ? Me!CmbTSerialNumber.Column(1) is an error message variable not yet created in this context
A new record is being added with the serial number and the rest of the fields being blank when the record is only supposed to be edited?
Most important the the current record after task no is chosen is not being pulled up.
Reply With Quote
  #2  
Old 04-12-2009, 02:37 PM
RuralGuy's Avatar
RuralGuy RuralGuy is offline Windows 7 Access 2007 (version 12.0)
Super Moderator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 3,848
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

If you would use the code tags (the # button in the toolbar) then your post would look like:
Code:
Private Sub cmbDSerialNumber_AfterUpdate()
   Dim rs As DAO.Recordset
   If Not IsNull(Me.cmbDSerialNumber) Then
      'Save before move.
      If Me.Dirty Then
         Me.Dirty = False
      End If
      'Search in the clone set.
      Set rs = Me.RecordsetClone
      rs.FindFirst "dserialnumber = '" & cmbDSerialNumber & "'"
      If rs.NoMatch Then
         MsgBox "There is no task for: " & cmbDSerialNumber & " Add Task?", vbYesNoCancel
      Else
         'Display the found record in the form.
         Me.Bookmark = rs.Bookmark
      End If
      Set rs = Nothing
   End If
End Sub
 
'User presses edit task command button
Private Sub EditTaskBttn_Click()
   DoCmd.OpenForm "EditTask", , , "[TSerialNumber] = '" & Me.cmbDSerialNumber.Column(0) & "'", acFormEdit
End Sub
 
' Loading Edit Task Form
Private Sub Form_Load()
   Me.TSerialNumber = Forms![Main Switchboard]!cmbDSerialNumber
   Me.Caption = "Serial Number: " & Me!TSerialNumber.Value
End Sub
 
'Query for Second Combo
SELECT TaskList.TSerialNumber, TaskList.[No], TaskList.Task
FROM Dockets INNER JOIN TaskList ON Dockets.DSerialNumber = TaskList.TSerialNumber
WHERE (((TaskList.TSerialNumber)=[Forms]![Main Switchboard]![cmbDSerialNumber]));
 
'Loading Second Combo
Private Sub CmbTSerialNumber_AfterUpdate()
   Me.RecordsetClone.FindFirst "[no] = " & Me!CmbTSerialNumber.Column(2)
   Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
 
'I put a breakpoint by
Me.RecordsetClone.FindFirst "[no] = " & Me!CmbTSerialNumber.Column(1)
'then I press F8 to step into the next 2 statements
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
Quite a bit easier to read.
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #3  
Old 04-12-2009, 02:40 PM
RuralGuy's Avatar
RuralGuy RuralGuy is offline Windows 7 Access 2007 (version 12.0)
Super Moderator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 3,848
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Are you aware of the fact that this code:
Code:
'User presses edit task command button
Private Sub EditTaskBttn_Click()
   DoCmd.OpenForm "EditTask", , , "[TSerialNumber] = '" & Me.cmbDSerialNumber.Column(0) & "'", acFormEdit
End Sub
...puts a filter on the "EditTask" form?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #4  
Old 04-12-2009, 02:48 PM
RuralGuy's Avatar
RuralGuy RuralGuy is offline Windows 7 Access 2007 (version 12.0)
Super Moderator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 3,848
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

After putting a filter on the "EditTask" form you then proceed to Dirty a record with:
Code:
Private Sub Form_Load()
   Me.TSerialNumber = Forms![Main Switchboard]!cmbDSerialNumber
   Me.Caption = "Serial Number: " & Me!TSerialNumber.Value
End Sub
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
  #5  
Old 04-13-2009, 12:22 PM
Novice
 
Join Date: Feb 2009
Posts: 6
cjamps is on a distinguished road
Default

I have commented out the form load statements. I have taken away the filter so the statement appears as
DoCmd.OpenForm "EditTask", , , , acFormEdit

When it gets to the following code:

Private Sub CmbTSerialNumber_AfterUpdate()
Me.RecordsetClone.FindFirst Me!CmbTSerialNumber.Column(1) = [No]
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

I still have the following problem:

'I put a breakpoint by
Me.RecordsetClone.FindFirst "[no] = " & Me!CmbTSerialNumber.Column(1)

'then I press F8 to step into the next 2 statements

Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub

In the immediate window Me!CmbTSerialNumber.Column(1) is the correct number but ? no is the correct task number is always = to 1. If I add a watch to both those variables they are empty. After the sub is finished ? no is empty and ? Me!CmbTSerialNumber.Column(1) is an error message variable not yet created in this context.
Reply With Quote
  #6  
Old 04-14-2009, 10:00 AM
RuralGuy's Avatar
RuralGuy RuralGuy is offline Windows 7 Access 2007 (version 12.0)
Super Moderator
 
Join Date: Mar 2007
Location: 8300' in the Colorado Rocky Mountains
Posts: 3,848
RuralGuy will become famous soon enoughRuralGuy will become famous soon enough
Default

Ant chance you are using the dredded Lookup fields?
__________________
(RG for short) aka Allan Bunch MS Access MVP - WinXP Pro, Win7 - acXP, ac07
If your issue is resolved...follow this link for directions on how to use the Solved thread tool!
Teaching is not filling a bucket but lighting a fire. Borrowed quote..."Docendo discimus"
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create report with multiple combo box selections form form? vanlanjl Reports 1 03-02-2009 08:54 AM
Updating Table field from Form Kunuk Access 0 02-26-2009 08:41 PM
Updating SQL server form Access form? slash75 Forms 1 09-06-2008 12:39 PM
Filtering subform combo from main form combo MUKUDU99 Forms 0 08-17-2008 10:19 AM
Updating Multiple Pass-Through Queries through a Form ryan05 Access 0 03-19-2006 08:52 PM


All times are GMT -8. The time now is 08:27 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.